Ordered dictionary of elements of type T.
More...
#include <sortdict.h>
|
|
class | Iterator |
| |
|
class | IteratorDict |
| |
template<class T>
class SIntDict< T >
Ordered dictionary of elements of type T.
Internally uses a QList<T> and a QIntDict<T>.
§ SIntDict()
Create an ordered dictionary.
- Parameters
-
| size | The size of the dictionary. Should be a prime number for best distribution of elements. |
§ ~SIntDict()
§ 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
-
| key | The unique key to use to quicky find the item later on. |
| d | The compound to add. |
- See also
- find()
§ at()
Returns the item at position i in the sorted dictionary
§ clear()
§ 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()
Returns the number of items stored in the dictionary
§ find()
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 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()
§ operator[]()
template<class T>
| T* SIntDict< T >::operator[] |
( |
int |
key | ) |
const |
|
inline |
§ 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
-
| key | The unique key to use to quicky find the item later on. |
| d | The compound to add. |
- See also
- find()
§ remove()
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()
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: