00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXDICT_H
00025 #define FXDICT_H
00026
00027 #ifndef FXOBJECT_H
00028 #include "FXObject.h"
00029 #endif
00030
00031 namespace FX {
00032
00033
00041 class FXAPI FXDict : public FXObject {
00042 FXDECLARE(FXDict)
00043 protected:
00044 struct FXDictEntry {
00045 FXchar *key;
00046 void *data;
00047 FXint hash;
00048 bool mark;
00049 };
00050 protected:
00051 FXDictEntry *dict;
00052 FXint total;
00053 FXint number;
00054 protected:
00055 static FXint hash(const FXchar* str);
00056 protected:
00057
00063 virtual void *createData(const void*);
00064
00070 virtual void deleteData(void*);
00071 public:
00072
00076 FXDict();
00077
00079 FXDict(const FXDict& orig);
00080
00082 FXDict& operator=(const FXDict& orig);
00083
00087 void size(FXint m);
00088
00092 FXint size() const { return total; }
00093
00097 FXint no() const { return number; }
00098
00104 void* insert(const FXchar* ky,const void* ptr,bool mrk=false);
00105
00111 void* replace(const FXchar* ky,const void* ptr,bool mrk=false);
00112
00116 void* remove(const FXchar* ky);
00117
00121 void* find(const FXchar* ky) const;
00122
00126 bool empty(FXint pos) const { return dict[pos].hash<0; }
00127
00131 const FXchar* key(FXuint pos) const { return dict[pos].key; }
00132
00136 void* data(FXuint pos) const { return dict[pos].data; }
00137
00141 bool mark(FXuint pos) const { return dict[pos].mark; }
00142
00146 FXint first() const;
00147
00151 FXint last() const;
00152
00153
00159 FXint next(FXint pos) const;
00160
00165 FXint prev(FXint pos) const;
00166
00168 void clear();
00169
00171 virtual ~FXDict();
00172 };
00173
00174 }
00175
00176 #endif