]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/hash.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxHashTable class
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "hash.h"
19 #include "wx/object.h"
23 * A hash table is an array of user-definable size with lists
24 * of data items hanging off the array positions. Usually there'll
25 * be a hit, so no search is required; otherwise we'll have to run down
26 * the list to find the desired item.
29 class WXDLLEXPORT wxHashTable
: public wxObject
31 DECLARE_DYNAMIC_CLASS(wxHashTable
)
38 unsigned int key_type
;
41 wxHashTable(int the_key_type
= wxKEY_INTEGER
, int size
= 1000);
44 void Destroy(void); // Robert Roebling
46 bool Create(int the_key_type
= wxKEY_INTEGER
, int size
= 1000);
48 // Note that there are 2 forms of Put, Get.
49 // With a key and a value, the *value* will be checked
50 // when a collision is detected. Otherwise, if there are
51 // 2 items with a different value but the same key,
52 // we'll retrieve the WRONG ONE. So where possible,
53 // supply the required value along with the key.
54 // In fact, the value-only versions make a key, and still store
55 // the value. The use of an explicit key might be required
56 // e.g. when combining several values into one key.
57 // When doing that, it's highly likely we'll get a collision,
58 // e.g. 1 + 2 = 3, 2 + 1 = 3.
60 // key and value are NOT necessarily the same
61 void Put(long key
, long value
, wxObject
*object
);
62 void Put(long key
, const wxChar
*value
, wxObject
*object
);
64 // key and value are the same
65 void Put(long value
, wxObject
*object
);
66 void Put(const wxChar
*value
, wxObject
*object
);
68 // key and value not the same
69 wxObject
*Get(long key
, long value
) const;
70 wxObject
*Get(long key
, const wxChar
*value
) const;
72 // key and value are the same
73 wxObject
*Get(long value
) const;
74 wxObject
*Get(const wxChar
*value
) const;
76 // Deletes entry and returns data if found
77 wxObject
*Delete(long key
);
78 wxObject
*Delete(const wxChar
*key
);
80 wxObject
*Delete(long key
, int value
);
81 wxObject
*Delete(long key
, const wxChar
*value
);
83 // Construct your own integer key from a string, e.g. in case
84 // you need to combine it with something
85 long MakeKey(const wxChar
*string
) const;
87 // Way of iterating through whole hash table (e.g. to delete everything)
88 // Not necessary, of course, if you're only storing pointers to
89 // objects maintained separately
94 void DeleteContents(bool flag
);