ISLEman
Classes | Public Member Functions | Friends | List of all members
SIntDict< T > Class Template Reference

Ordered dictionary of elements of type T. More...

#include <sortdict.h>

Inheritance diagram for SIntDict< T >:
LetterToIndexMap< T >

Classes

class  Iterator
 
class  IteratorDict
 

Public Member Functions

 SIntDict (int size=17)
 
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 compareValues (const T *item1, const T *item2) const
 
void clear ()
 
int count () const
 

Friends

class Iterator
 
class IteratorDict
 

Detailed Description

template<class T>
class SIntDict< T >

Ordered dictionary of elements of type T.

Internally uses a QList<T> and a QIntDict<T>.

Constructor & Destructor Documentation

§ SIntDict()

template<class T>
SIntDict< T >::SIntDict ( int  size = 17)
inline

Create an ordered dictionary.

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

§ ~SIntDict()

template<class T>
virtual SIntDict< T >::~SIntDict ( )
inlinevirtual

Destroys the dictionary

Member Function Documentation

§ append()

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
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See also
find()

§ at()

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

Returns the item at position i in the sorted dictionary

§ clear()

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

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

See also
setAutoDelete

§ compareValues()

template<class T>
virtual int SIntDict< T >::compareValues ( const T *  item1,
const T *  item2 
) const
inlinevirtual

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

See also
inSort()

§ count()

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

Returns the number of items stored in the dictionary

§ find()

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

Looks up a compound given its key.

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

§ inSort()

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

Inserts a compound into the dictionary in a sorted way.

Parameters
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See also
find()

§ operator[]()

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

Equavalent to find().

§ prepend()

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
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See also
find()

§ remove()

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

Remove an item from the dictionary

§ setAutoDelete()

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

Indicates whether or not the dictionary owns its elements

§ sort()

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)).


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