]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: hash.h | |
3 | // Purpose: documentation for wxHashTable class | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxHashTable | |
11 | @wxheader{hash.h} | |
7c913512 | 12 | |
23324ae1 FM |
13 | @b Please note that this class is retained for backward compatibility |
14 | reasons; you should use wxHashMap. | |
7c913512 | 15 | |
23324ae1 FM |
16 | This class provides hash table functionality for wxWidgets, and for an |
17 | application if it wishes. Data can be hashed on an integer or string | |
18 | key. | |
7c913512 | 19 | |
23324ae1 FM |
20 | @library{wxbase} |
21 | @category{containers} | |
7c913512 | 22 | |
23324ae1 FM |
23 | @seealso |
24 | wxList | |
25 | */ | |
26 | class wxHashTable : public wxObject | |
27 | { | |
28 | public: | |
29 | /** | |
4cc4bfaf FM |
30 | Constructor. @a key_type is one of wxKEY_INTEGER, or wxKEY_STRING, |
31 | and indicates what sort of keying is required. @a size is optional. | |
23324ae1 FM |
32 | */ |
33 | wxHashTable(unsigned int key_type, int size = 1000); | |
34 | ||
35 | /** | |
36 | Destroys the hash table. | |
37 | */ | |
38 | ~wxHashTable(); | |
39 | ||
40 | /** | |
41 | The counterpart of @e Next. If the application wishes to iterate | |
42 | through all the data in the hash table, it can call @e BeginFind and | |
43 | then loop on @e Next. | |
44 | */ | |
45 | void BeginFind(); | |
46 | ||
47 | /** | |
48 | Clears the hash table of all nodes (but as usual, doesn't delete user data). | |
49 | */ | |
50 | void Clear(); | |
51 | ||
52 | //@{ | |
53 | /** | |
54 | Deletes entry in hash table and returns the user's data (if found). | |
55 | */ | |
4cc4bfaf FM |
56 | wxObject* Delete(long key); |
57 | wxObject* Delete(const wxString& key); | |
23324ae1 FM |
58 | //@} |
59 | ||
60 | /** | |
61 | If set to @true data stored in hash table will be deleted when hash table object | |
62 | is destroyed. | |
63 | */ | |
64 | void DeleteContents(bool flag); | |
65 | ||
66 | //@{ | |
67 | /** | |
68 | Gets data from the hash table, using an integer or string key (depending on | |
69 | which | |
70 | has table constructor was used). | |
71 | */ | |
4cc4bfaf FM |
72 | wxObject* Get(long key); |
73 | wxObject* Get(const char* key); | |
23324ae1 FM |
74 | //@} |
75 | ||
76 | /** | |
77 | Returns the number of elements in the hash table. | |
78 | */ | |
328f5751 | 79 | size_t GetCount() const; |
23324ae1 FM |
80 | |
81 | /** | |
82 | Makes an integer key out of a string. An application may wish to make a key | |
83 | explicitly (for instance when combining two data values to form a key). | |
84 | */ | |
85 | long MakeKey(const wxString& string); | |
86 | ||
87 | /** | |
88 | If the application wishes to iterate through all the data in the hash | |
89 | table, it can call @e BeginFind and then loop on @e Next. This function | |
90 | returns a @b Node() pointer (or @NULL if there are no more nodes). | |
91 | The return value is functionally equivalent to @b wxNode but might not be | |
92 | implemented as a @b wxNode. The user will probably only wish to use the | |
93 | @b GetData method to retrieve the data; the node may also be deleted. | |
94 | */ | |
4cc4bfaf | 95 | wxHashTable::Node* Next(); |
23324ae1 FM |
96 | |
97 | //@{ | |
98 | /** | |
99 | Inserts data into the hash table, using an integer or string key (depending on | |
100 | which | |
101 | has table constructor was used). The key string is copied and stored by the hash | |
102 | table implementation. | |
103 | */ | |
4cc4bfaf FM |
104 | void Put(long key, wxObject* object); |
105 | void Put(const char* key, wxObject* object); | |
23324ae1 FM |
106 | //@} |
107 | }; |