21 #ifndef FXDICTIONARY_H 22 #define FXDICTIONARY_H 51 void used(FXival u){ ((FXival*)table)[-2]=u; }
54 void free(FXival f){ ((FXival*)table)[-3]=f; }
57 FXbool resize(FXival n);
64 FXDictionary(
const FXDictionary& other);
67 FXival
no()
const {
return ((FXival*)table)[-1]; }
70 FXival
used()
const {
return ((FXival*)table)[-2]; }
73 FXival
free()
const {
return ((FXival*)table)[-3]; }
76 FXbool
empty()
const {
return ((FXival*)table)[-1]<=1; }
85 FXival find(
const FXchar* ky)
const;
91 FXbool
has(
const FXchar* ky)
const {
return 0<=find(ky); }
97 void*& at(
const FXchar* ky);
100 void *
const& at(
const FXchar* ky)
const;
112 void *
const&
operator[](
const FXchar* ky)
const {
return at(ky); }
121 void*
insert(
const FXchar* ky,
void* ptr=
nullptr){
return swap(ptr,at(ky)); }
127 void*
remove(
const FXchar* ky);
130 void*
remove(
const FXString& ky){
return remove(ky.text()); }
133 void* erase(FXival pos);
136 FXbool
empty(FXival pos)
const {
return table[pos].key.
empty(); }
142 void*&
data(FXival pos){
return table[pos].data; }
145 void *
const&
data(FXival pos)
const {
return table[pos].data; }
void *& operator[](const FXString &ky)
Return reference to slot assocated with given key.
Definition: FXDictionary.h:115
void *& at(const FXString &ky)
Return reference to slot assocated with given key.
Definition: FXDictionary.h:103
void *const & at(const FXString &ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionary.h:106
Definition: FXDictionary.h:38
The dictionary class is a fast-access hash table, mapping strings to void-pointers.
Definition: FXDictionary.h:36
FXbool has(const FXchar *ky) const
Check if key is mapped.
Definition: FXDictionary.h:91
void *& data(FXival pos)
Return reference to slot at position pos.
Definition: FXDictionary.h:142
FXchar * text()
Get text contents as pointer.
Definition: FXString.h:119
FXbool empty() const
See if string is empty.
Definition: FXString.h:125
const FXString & key(FXival pos) const
Return key at position pos.
Definition: FXDictionary.h:139
void *const & data(FXival pos) const
Return constant reference to slot at position pos.
Definition: FXDictionary.h:145
void *const & operator[](const FXchar *ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionary.h:112
FXival free() const
Return number of free slots in the table.
Definition: FXDictionary.h:73
Definition: FX4Splitter.h:28
FXival find(const FXString &ky) const
Find position of given key, returning -1 if not found.
Definition: FXDictionary.h:88
void * insert(const FXchar *ky, void *ptr=nullptr)
Insert association with given key; return old value, if any.
Definition: FXDictionary.h:121
void * insert(const FXString &ky, void *ptr=nullptr)
Insert association with given key; return old value, if any.
Definition: FXDictionary.h:124
FXival used() const
Return number of used slots in the table.
Definition: FXDictionary.h:70
void *const & operator[](const FXString &ky) const
Return constant reference to slot assocated with given key.
Definition: FXDictionary.h:118
FXbool empty() const
See if map is empty.
Definition: FXDictionary.h:76
FXival no() const
Return the size of the table, including the empty slots.
Definition: FXDictionary.h:67
FXbool has(const FXString &ky) const
Check if key is mapped.
Definition: FXDictionary.h:94
FXbool empty(FXival pos) const
Return true if slot is empty.
Definition: FXDictionary.h:136
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42
void *& operator[](const FXchar *ky)
Return reference to slot assocated with given key.
Definition: FXDictionary.h:109