![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
|
The dictionary class maintains a fast-access hash table of entities indexed by a character string. More...
#include <FXDict.h>
Classes | |
| struct | Entry |
Public Member Functions | |
| FXDict () | |
| Construct an empty dictionary. | |
| FXbool | size (FXint m) |
| Resize the table to the given size. | |
| FXint | size () const |
| Return the size of the table, including the empty slots. | |
| FXint | no () const |
| Return the total number of entries in the table. | |
| void * | insert (const FXchar *ky, void *ptr=NULL, FXbool mrk=false) |
| Insert a new entry into the table given key and mark. | |
| void * | replace (const FXchar *ky, void *ptr=NULL, FXbool mrk=false) |
| Replace data at key, if the entry's mark is less than or equal to the given mark. | |
| void * | remove (const FXchar *ky) |
| Remove data given key. | |
| void * | find (const FXchar *ky) const |
| Find data pointer given key. | |
| FXbool | empty (FXint pos) const |
| Return true if slot is empty. | |
| const FXchar * | key (FXint pos) const |
| Return key at position pos. | |
| void * | data (FXint pos) const |
| Return data pointer at position pos. | |
| FXbool | mark (FXint pos) const |
| Return mark flag of entry at position pos. | |
| FXint | first () const |
| Return position of first filled slot, or >= total. | |
| FXint | last () const |
| Return position of last filled slot or -1. | |
| FXint | next (FXint pos) const |
| Return position of next filled slot in hash table or a value greater than or equal to total if no filled slot was found. | |
| FXint | prev (FXint pos) const |
| Return position of previous filled slot in hash table or a -1 if no filled slot was found. | |
| void | clear () |
| Clear all entries. | |
| virtual | ~FXDict () |
| Destructor. | |
Protected Member Functions | |
| virtual void * | createData (void *) |
| Overload this function in a derived class to return the data pointer given an input pointer; the default implementation just returns the input pointer. | |
| virtual void | deleteData (void *) |
| Overload this function in a derived class to delete the pointer previously returned by createData(); the default implementation does nothing. | |
Static Protected Member Functions | |
| static FXint | hash (const FXchar *str) |
Protected Attributes | |
| FXArray< Entry > | table |
| FXint | used |
| FXint | free |
Static Protected Attributes | |
| static const Entry | init |
The dictionary class maintains a fast-access hash table of entities indexed by a character string.
It is typically used to map strings to pointers; however, overloading the createData() and deleteData() members allows any type of data to be indexed by strings.
| void* FX::FXDict::insert | ( | const FXchar * | ky, |
| void * | ptr = NULL, |
||
| FXbool | mrk = false |
||
| ) |
Insert a new entry into the table given key and mark.
If there is already an entry with that key, leave it unchanged, otherwise insert the new entry.
| void* FX::FXDict::replace | ( | const FXchar * | ky, |
| void * | ptr = NULL, |
||
| FXbool | mrk = false |
||
| ) |
Replace data at key, if the entry's mark is less than or equal to the given mark.
If there was no existing entry, a new entry is inserted with the given mark.
|
|