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

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

#include <sortdict.h>

Classes

class  Iterator
 
class  IteratorDict
 

Public Member Functions

 SDict (int size=17, bool caseSensitive=TRUE)
 
virtual ~SDict ()
 
void append (const char *key, const T *d)
 
void prepend (const char *key, const T *d)
 
bool remove (const char *key)
 
T * take (const char *key)
 
void sort ()
 
void inSort (const char *key, const T *d)
 
void insertAt (int i, const char *key, const T *d)
 
void setAutoDelete (bool val)
 
T * find (const char *key)
 
T * find (const QCString &key)
 
T * find (const QString &key)
 
int findAt (const QCString &key)
 
T * operator[] (const char *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 SDict< T >

Ordered dictionary of elements of type T.

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

Constructor & Destructor Documentation

§ SDict()

template<class T>
SDict< T >::SDict ( int  size = 17,
bool  caseSensitive = TRUE 
)
inline

Create an ordered dictionary.

Parameters
sizeThe size of the dictionary. Should be a prime number for best distribution of elements.
caseSensitiveindicated whether the keys should be sorted in a case sensitive way.

§ ~SDict()

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

Destroys the dictionary

Member Function Documentation

§ append()

template<class T>
void SDict< T >::append ( const char *  key,
const T *  d 
)
inline

Appends an element 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* SDict< T >::at ( uint  i)
inline

Returns the item at position i in the sorted dictionary

§ clear()

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

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

See also
setAutoDelete

§ compareValues()

template<class T>
virtual int SDict< 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()

Reimplemented in DirSDict.

§ count()

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

Returns the number of items stored in the dictionary

§ find()

template<class T>
T* SDict< T >::find ( const char *  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 SDict< T >::inSort ( const char *  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* SDict< T >::operator[] ( const char *  key) const
inline

Equavalent to find().

§ prepend()

template<class T>
void SDict< T >::prepend ( const char *  key,
const T *  d 
)
inline

Prepends an element 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 SDict< T >::remove ( const char *  key)
inline

Remove an item from the dictionary

§ setAutoDelete()

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

Indicates whether or not the dictionary owns its elements

§ sort()

template<class T>
void SDict< 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)).

§ take()

template<class T>
T* SDict< T >::take ( const char *  key)
inline

Take an item out of the dictionary without deleting it


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