00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXDICT_H
00022 #define FXDICT_H
00023
00024 #ifndef FXOBJECT_H
00025 #include "FXObject.h"
00026 #endif
00027
00028 namespace FX {
00029
00030
00038 class FXAPI FXDict : public FXObject {
00039 FXDECLARE(FXDict)
00040 protected:
00041 struct Entry {
00042 FXchar *key;
00043 void *data;
00044 FXint hash;
00045 FXbool mark;
00046 };
00047 protected:
00048 FXArray<Entry> table;
00049 FXint used;
00050 FXint free;
00051 protected:
00052 static const Entry init;
00053 protected:
00054 static FXint hash(const FXchar* str);
00055 private:
00056 FXDict(const FXDict&);
00057 FXDict &operator=(const FXDict&);
00058 protected:
00059
00065 virtual void *createData(void*);
00066
00072 virtual void deleteData(void*);
00073 public:
00074
00078 FXDict();
00079
00083 FXbool size(FXint m);
00084
00088 FXint size() const { return table.no(); }
00089
00093 FXint no() const { return used; }
00094
00100 void* insert(const FXchar* ky,void* ptr=NULL,FXbool mrk=false);
00101
00107 void* replace(const FXchar* ky,void* ptr=NULL,FXbool mrk=false);
00108
00112 void* remove(const FXchar* ky);
00113
00117 void* find(const FXchar* ky) const;
00118
00122 FXbool empty(FXint pos) const { return !table[pos].key; }
00123
00127 const FXchar* key(FXint pos) const { return table[pos].key; }
00128
00132 void* data(FXint pos) const { return table[pos].data; }
00133
00137 FXbool mark(FXint pos) const { return table[pos].mark; }
00138
00142 FXint first() const;
00143
00147 FXint last() const;
00148
00149
00155 FXint next(FXint pos) const;
00156
00161 FXint prev(FXint pos) const;
00162
00164 void clear();
00165
00167 virtual ~FXDict();
00168 };
00169
00170 }
00171
00172 #endif