SIntDict< T > Class Template Reference

#include <sortdict.h>

List of all members.

Public Member Functions

 SIntDict (int size)
virtual ~SIntDict ()
void append (int key, const T *d)
void prepend (int key, const T *d)
bool remove (int key)
void sort ()
void inSort (int key, const T *d)
void setAutoDelete (bool val)
T * find (int key)
T * operator[] (int key) const
T * at (uint i)
virtual int compareItems (GCI item1, GCI item2)
void clear ()
int count ()

Friends

class Iterator

Classes

class  Iterator


Detailed Description

template<class T>
class SIntDict< T >

Ordered dictionary of elements of type T. Internally uses a QList<T> and a QIntDict<T>.

Definition at line 426 of file sortdict.h.


Constructor & Destructor Documentation

template<class T>
SIntDict< T >::SIntDict ( int  size  )  [inline]

Create an ordered dictionary.

Parameters:
size The size of the dictionary. Should be a prime number for best distribution of elements.

Definition at line 438 of file sortdict.h.

template<class T>
virtual SIntDict< T >::~SIntDict (  )  [inline, virtual]

Destroys the dictionary

Definition at line 450 of file sortdict.h.


Member Function Documentation

template<class T>
void SIntDict< T >::append ( int  key,
const T *  d 
) [inline]

Appends a compound to the dictionary. The element is owned by the dictionary.

Parameters:
key The unique key to use to quicky find the item later on.
d The compound to add.
See also:
find()

Definition at line 462 of file sortdict.h.

template<class T>
void SIntDict< T >::prepend ( int  key,
const T *  d 
) [inline]

Prepend a compound to the dictionary. The element is owned by the dictionary.

Parameters:
key The unique key to use to quicky find the item later on.
d The compound to add.
See also:
find()

Definition at line 480 of file sortdict.h.

template<class T>
bool SIntDict< T >::remove ( int  key  )  [inline]

Remove an item from the dictionary

Definition at line 493 of file sortdict.h.

template<class T>
void SIntDict< T >::sort (  )  [inline]

Sorts the members of the dictionary. First appending a number of members and then sorting them is faster (O(NlogN) than using inSort() for each member (O(N^2)).

Definition at line 503 of file sortdict.h.

template<class T>
void SIntDict< T >::inSort ( int  key,
const T *  d 
) [inline]

Inserts a compound into the dictionary in a sorted way.

Parameters:
key The unique key to use to quicky find the item later on.
d The compound to add.
See also:
find()

Definition at line 513 of file sortdict.h.

template<class T>
void SIntDict< T >::setAutoDelete ( bool  val  )  [inline]

Indicates whether or not the dictionary owns its elements

Definition at line 526 of file sortdict.h.

Referenced by addMembersToMemberGroup(), GroupDef::GroupDef(), and NamespaceDef::NamespaceDef().

template<class T>
T* SIntDict< T >::find ( int  key  )  [inline]

Looks up a compound given its key.

Parameters:
key The key to identify this element.
Returns:
The requested compound or zero if it cannot be found.
See also:
append()

Definition at line 536 of file sortdict.h.

template<class T>
T* SIntDict< T >::operator[] ( int  key  )  const [inline]

Equavalent to find().

Definition at line 542 of file sortdict.h.

template<class T>
T* SIntDict< T >::at ( uint  i  )  [inline]

Returns the item at position i in the sorted dictionary

Definition at line 548 of file sortdict.h.

template<class T>
virtual int SIntDict< T >::compareItems ( GCI  item1,
GCI  item2 
) [inline, virtual]

Function that is used to compare two items when sorting. Overload this to properly sort items.

See also:
inSort()

Definition at line 557 of file sortdict.h.

template<class T>
void SIntDict< T >::clear (  )  [inline]

Clears the dictionary. Will delete items if setAutoDelete() was set to TRUE.

See also:
setAutoDelete

Definition at line 566 of file sortdict.h.

template<class T>
int SIntDict< T >::count (  )  [inline]

Returns the number of items stored in the dictionary

Definition at line 574 of file sortdict.h.


Friends And Related Function Documentation

template<class T>
friend class Iterator [friend]

Definition at line 579 of file sortdict.h.


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



Generated on Mon Mar 31 10:59:03 2008 by  doxygen 1.5.1