GCpp general purpose C++ library  version 1.0
GSortListT< T > Class Template Reference

#include <GSortListT.hh>

Inheritance diagram for GSortListT< T >:
GListT< T > GCollectionT< T > GNamedListT< T >

Public Member Functions

template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
virtual GSortListT< T > * Clone () const
 
virtual const char * ClassName () const
 
 GSortListT (u_int fl=0)
 
 GSortListT (const GSortListT< T > &list)
 
 GSortListT (const GListT< T > &list)
 
 GSortListT (const GListT< T > &list, u_int fl)
 
GSortListT< T > & operator= (const GListT< T > &list)
 
virtual ~GSortListT ()
 
virtual void ReverseSort ()
 
virtual int Compare (const T &obj1, const T &obj2) const
 
virtual void Sort ()
 
virtual bool IsSorted () const
 
- Public Member Functions inherited from GListT< T >
template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
 GListT (u_int opts=0)
 
 GListT (const GListT< T > &list)
 
 GListT (const GListT< T > &list, u_int opts)
 
GListT< T > & operator= (const GListT< T > &list)
 
virtual ~GListT ()
 
virtual GListIterT< T > Begin () const
 
virtual GListIterT< T > End () const
 
virtual bool Exist (const T *ptr) const
 
virtual GListIterT< T > Find (const T *ptr) const
 
virtual GListIterT< T > FindNext (const T *ptr) const
 
virtual GListIterT< T > FindPrevious (const T *ptr) const
 
virtual GListIterT< T > FindFirst (const T *ptr) const
 
virtual GListIterT< T > FindLast (const T *ptr) const
 
GListIterT< T > Current () const
 
GListIterT< T > Previous () const
 
GListIterT< T > Next () const
 
GListIterT< T > First () const
 
GListIterT< T > Last () const
 
GListIterT< T > Goto (u_int n=0) const
 
T & At (u_int n) const
 
int Index () const
 
virtual int Move (int n)
 
virtual bool MoveUp ()
 
virtual bool MoveDown ()
 
virtual bool MoveTop ()
 
virtual bool MoveBottom ()
 
virtual GListIterT< T > Add (T *obj_ptr)
 
virtual GListIterT< T > Insert (T *obj_ptr)
 
virtual GListIterT< T > Append (T *obj_ptr)
 
virtual GListIterT< T > Prepend (T *obj_ptr)
 
virtual GListIterT< T > Add (T &obj_ptr)
 
virtual GListIterT< T > Insert (T &obj_ptr)
 
virtual GListIterT< T > Append (T &obj_ptr)
 
virtual GListIterT< T > Prepend (T &obj_ptr)
 
virtual T * Take ()
 
virtual T * Take (const T *ptr)
 
virtual bool Remove ()
 
virtual bool Remove (const T *ptr, bool all=true)
 
virtual void Empty ()
 
- Public Member Functions inherited from GCollectionT< T >
template<class Q >
bool IsInstanceOf () const
 
template<class Q >
bool IsInstanceOf ()
 
 GCollectionT (u_int flg=0)
 
virtual ~GCollectionT ()
 
virtual u_int GetSize () const
 
virtual u_int GetCount () const
 
virtual u_int GetOptions () const
 
bool CheckOptions (u_int opts) const
 
bool FixPositionOption () const
 
bool IsSortable () const
 
bool IsAlwaysSorted () const
 
bool IsReverseSorted () const
 
bool UniqueNameOption () const
 
bool IsCaseSensitive () const
 
bool DictSortOption () const
 

Static Public Member Functions

static const char * StaticClassName ()
 
- Static Public Member Functions inherited from GListT< T >
static const char * StaticClassName ()
 
static GListIterT< T > Null ()
 
- Static Public Member Functions inherited from GCollectionT< T >
static const char * StaticClassName ()
 

Protected Member Functions

virtual GListIterT< T > __Add (T *item)
 
virtual GListIterT< T > __Insert (T *item)
 
virtual GListIterT< T > __AddSorted (T *item)
 
- Protected Member Functions inherited from GListT< T >
virtual GListIterT< T > * __Exist (const T *ptr, GListIterT< T > *except=NULL) const
 
virtual GListIterT< T > * __Find (const T *ptr, GListIterT< T > *except=NULL) const
 
virtual T * __Take ()
 
virtual void __Swap (GListIterT< T > *iter)
 
virtual bool __MoveUp ()
 
virtual bool __MoveDown ()
 

Additional Inherited Members

- Protected Attributes inherited from GListT< T >
GListIterT< T > ** first_item
 Iterator on first object in the list.
 
GListIterT< T > ** last_item
 Iterator on last object in the list.
 
GListIterT< T > ** current_item
 Iterator on current object in the list.
 
- Protected Attributes inherited from GCollectionT< T >
u_int options
 Collection option flags.
 
u_int count_item
 Number of objects in the collection.
 

Detailed Description

template<class T>
class GSortListT< T >

Template class to define a sortable list of objects.

If the gcollection::gAlwaysSorted flags are set, then elements are inserted at their sorted position, and cannot be moved. Else they are inserted at current position, like in the base class, and the list is sorted only if the Sort() function is called.

The objects class must define the Compare() function, on which the sorting is based (returning -1, 0 or 1).

See GCpp template classes for more information about the template classes.

Constructor & Destructor Documentation

template<class T >
GSortListT< T >::GSortListT ( u_int  fl = 0)
inline

Default constructor of an empty sortable list.

Parameters
floption flags (the bit gcollection::gIsSortable is set anyway)

References GDebugConst.

template<class T>
GSortListT< T >::GSortListT ( const GSortListT< T > &  list)
inline

Constructor copying the argument list. The list to copy does not need to be sortable, but the copied objects will be placed according to the current list options.

Parameters
listlist to copy

References GDebugConst.

template<class T>
GSortListT< T >::GSortListT ( const GListT< T > &  list)
inline

Constructor copying the argument list. The list to copy does not need to be sortable, but the copied objects will be placed according to the current list options.

Parameters
listlist to copy

References GDebugConst.

template<class T>
GSortListT< T >::GSortListT ( const GListT< T > &  list,
u_int  fl 
)
inline

Constructor copying the argument list, and specifying option flags. The list to copy does not need to be sortable, but the copied objects will be placed according to the current list options.

Parameters
listlist to copy
floption flags (the bit gcollection::gIsSortable is set anyway)

References GDebugConst.

template<class T >
GSortListT< T >::~GSortListT ( )
inlinevirtual

Destructor: does not more than the base class.

References GDebugDest.

Member Function Documentation

template<class T>
GListIterT< T > GSortListT< T >::__Add ( T *  item)
protectedvirtual

Internal function modified from the base class in order to take into account the sorting.

Parameters
itempointer on the object to be added in the list.

Reimplemented from GListT< T >.

Reimplemented in GTreeBranchT< T >, GNamedListT< T >, GNamedListT< GTreeNodeT< T > >, and GNamedListT< GItem >.

References GListT< T >::__Add(), GDebugClass, and GGetString().

Referenced by GNamedListT< T >::__Add().

template<class T>
GListIterT< T > GSortListT< T >::__AddSorted ( T *  item)
protectedvirtual

This function adds an object at its correct place in a sorted list.

Parameters
itempointer on the object to be added in the list.

References GListT< T >::__Add(), GListT< T >::__Insert(), GListT< T >::Current(), GListT< T >::First(), GDebugClass, GGetStringHexa(), and GListT< T >::Null().

template<class T>
GListIterT< T > GSortListT< T >::__Insert ( T *  item)
protectedvirtual

Internal function modified from the base class in order to take into account the sorting.

Parameters
itempointer on the object to be added in the list.

Reimplemented from GListT< T >.

Reimplemented in GTreeBranchT< T >, GNamedListT< T >, GNamedListT< GTreeNodeT< T > >, and GNamedListT< GItem >.

References GListT< T >::__Insert(), GDebugClass, and GGetString().

Referenced by GNamedListT< T >::__Insert().

template<class T>
int GSortListT< T >::Compare ( const T &  obj1,
const T &  obj2 
) const
inlinevirtual

Comparison of 2 objects of the elements class, base on the Compare function of the objects class (that must be defined). The function returns -1, 0 or 1 depending if obj1 is respectively before, equal or after obj2.

Parameters
obj1first object
obj2second object

Reimplemented in GNamedListT< T >, GNamedListT< GTreeNodeT< T > >, and GNamedListT< GItem >.

template<class T>
template<class Q >
bool GSortListT< T >::IsInstanceOf ( ) const
inline

Macro from GCpp library that defines the following functions:

  • ClassName(): return the real class name of the object
  • StaticClassName(): return the used class name of the object (that may be a base class of the real object).
  • IsInstanceOf<T>(): return true if the current object is an instance of the template class name argument
  • Clone(): return an allocated copy of the object.
template<class T >
bool GSortListT< T >::IsSorted ( ) const
virtual

Return true if the list is sorted according sorting order.

References GIterT< T >::GetPointer(), and GListIterT< T >::Next().

template<class T>
GSortListT< T > & GSortListT< T >::operator= ( const GListT< T > &  list)
inline

Affectation operator The list to copy does not need to be sortable, but the copied objects will be placed according to the current list options.

Parameters
listlist to copy

References G_AFFECT_MOTHER, and GDebugClass.

template<class T >
void GSortListT< T >::ReverseSort ( )
inlinevirtual

Flip the sorting order.

References gcollection::gReverseSort.

template<class T >
void GSortListT< T >::Sort ( )
virtual

Sort the list (according to sorting order option).

References GIterT< T >::GetPointer(), GListIterT< T >::NextIterPtr(), and GListIterT< T >::PreviousIterPtr().


The documentation for this class was generated from the following files: