Ordered dictionary of elements of type T.
More...
#include <sortdict.h>
|
| | 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 |
| |
|
|
class | Iterator |
| |
|
class | IteratorDict |
| |
template<class T>
class SDict< T >
Ordered dictionary of elements of type T.
Internally uses a QList<T> and a QDict<T>.
§ SDict()
template<class T>
| SDict< T >::SDict |
( |
int |
size = 17, |
|
|
bool |
caseSensitive = TRUE |
|
) |
| |
|
inline |
Create an ordered dictionary.
- Parameters
-
| size | The size of the dictionary. Should be a prime number for best distribution of elements. |
| caseSensitive | indicated whether the keys should be sorted in a case sensitive way. |
§ ~SDict()
§ 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
-
| key | The unique key to use to quicky find the item later on. |
| d | The 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 |
§ 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
-
| key | The 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
-
| key | The unique key to use to quicky find the item later on. |
| d | The compound to add. |
- See also
- find()
§ operator[]()
template<class T>
| T* SDict< T >::operator[] |
( |
const char * |
key | ) |
const |
|
inline |
§ 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
-
| key | The unique key to use to quicky find the item later on. |
| d | The 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: