1998-05-20 14:25:30 +00:00
|
|
|
\section{\class{wxHashTable}}\label{wxhashtable}
|
|
|
|
|
2002-01-29 21:31:16 +00:00
|
|
|
{\bf Please note} that this class is retained for backward compatibility
|
|
|
|
reasons; you should use \helpref{wxHashMap}{wxhashmap}.
|
|
|
|
|
2004-05-04 08:27:20 +00:00
|
|
|
This class provides hash table functionality for wxWidgets, and for an
|
1998-05-20 14:25:30 +00:00
|
|
|
application if it wishes. Data can be hashed on an integer or string
|
|
|
|
key.
|
|
|
|
|
|
|
|
\wxheading{Derived from}
|
|
|
|
|
|
|
|
\helpref{wxObject}{wxobject}
|
|
|
|
|
1999-02-15 20:41:29 +00:00
|
|
|
\wxheading{Include files}
|
|
|
|
|
|
|
|
<wx/hash.h>
|
|
|
|
|
2007-07-28 12:21:03 +00:00
|
|
|
\wxheading{Library}
|
|
|
|
|
|
|
|
\helpref{wxBase}{librarieslist}
|
|
|
|
|
1998-05-20 14:25:30 +00:00
|
|
|
\wxheading{Example}
|
|
|
|
|
|
|
|
Below is an example of using a hash table.
|
|
|
|
|
|
|
|
\begin{verbatim}
|
2004-06-03 09:42:50 +00:00
|
|
|
wxHashTable table(wxKEY_STRING);
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
wxPoint *point = new wxPoint(100, 200);
|
|
|
|
table.Put("point 1", point);
|
|
|
|
|
|
|
|
....
|
|
|
|
|
|
|
|
wxPoint *found_point = (wxPoint *)table.Get("point 1");
|
|
|
|
\end{verbatim}
|
|
|
|
|
|
|
|
A hash table is implemented as an array of pointers to lists. When no
|
|
|
|
data has been stored, the hash table takes only a little more space than
|
|
|
|
this array (default size is 1000). When a data item is added, an
|
|
|
|
integer is constructed from the integer or string key that is within the
|
|
|
|
bounds of the array. If the array element is NULL, a new (keyed) list is
|
|
|
|
created for the element. Then the data object is appended to the list,
|
|
|
|
storing the key in case other data objects need to be stored in the list
|
|
|
|
also (when a `collision' occurs).
|
|
|
|
|
|
|
|
Retrieval involves recalculating the array index from the key, and searching
|
|
|
|
along the keyed list for the data object whose stored key matches the passed
|
|
|
|
key. Obviously this is quicker when there are fewer collisions, so hashing
|
|
|
|
will become inefficient if the number of items to be stored greatly exceeds
|
|
|
|
the size of the hash table.
|
|
|
|
|
|
|
|
\wxheading{See also}
|
|
|
|
|
|
|
|
\helpref{wxList}{wxlist}
|
|
|
|
|
|
|
|
\latexignore{\rtfignore{\wxheading{Members}}}
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::wxHashTable}\label{wxhashtablector}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{}{wxHashTable}{\param{unsigned int}{ key\_type}, \param{int}{ size = 1000}}
|
|
|
|
|
|
|
|
Constructor. {\it key\_type} is one of wxKEY\_INTEGER, or wxKEY\_STRING,
|
|
|
|
and indicates what sort of keying is required. {\it size} is optional.
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::\destruct{wxHashTable}}\label{wxhashtabledtor}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{}{\destruct{wxHashTable}}{\void}
|
|
|
|
|
|
|
|
Destroys the hash table.
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::BeginFind}\label{wxhashtablebeginfind}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{void}{BeginFind}{\void}
|
|
|
|
|
|
|
|
The counterpart of {\it Next}. If the application wishes to iterate
|
|
|
|
through all the data in the hash table, it can call {\it BeginFind} and
|
|
|
|
then loop on {\it Next}.
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::Clear}\label{wxhashtableclear}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{void}{Clear}{\void}
|
|
|
|
|
|
|
|
Clears the hash table of all nodes (but as usual, doesn't delete user data).
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::Delete}\label{wxhashtabledelete}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{wxObject *}{Delete}{\param{long}{ key}}
|
|
|
|
|
|
|
|
\func{wxObject *}{Delete}{\param{const wxString\& }{ key}}
|
|
|
|
|
|
|
|
Deletes entry in hash table and returns the user's data (if found).
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::DeleteContents}\label{wxhashtabledeletecontents}
|
1999-12-22 22:23:35 +00:00
|
|
|
|
|
|
|
\func{void}{DeleteContents}{\param{bool}{ flag}}
|
|
|
|
|
2003-01-18 00:16:34 +00:00
|
|
|
If set to true data stored in hash table will be deleted when hash table object
|
1999-12-22 22:23:35 +00:00
|
|
|
is destroyed.
|
|
|
|
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::Get}\label{wxhashtableget}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{wxObject *}{Get}{\param{long}{ key}}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
\func{wxObject *}{Get}{\param{const char*}{ key}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
Gets data from the hash table, using an integer or string key (depending on which
|
|
|
|
has table constructor was used).
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::MakeKey}\label{wxhashtablemakekey}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{long}{MakeKey}{\param{const wxString\& }{string}}
|
|
|
|
|
|
|
|
Makes an integer key out of a string. An application may wish to make a key
|
|
|
|
explicitly (for instance when combining two data values to form a key).
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::Next}\label{wxhashtablenext}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2003-11-02 15:32:24 +00:00
|
|
|
\func{wxHashTable::Node *}{Next}{\void}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
If the application wishes to iterate through all the data in the hash
|
|
|
|
table, it can call {\it BeginFind} and then loop on {\it Next}. This function
|
2003-11-02 15:32:24 +00:00
|
|
|
returns a {\bf wxHashTable::Node} pointer (or NULL if there are no more nodes).
|
|
|
|
The return value is functionally equivalent to \textbf{wxNode} but might not be
|
|
|
|
implemented as a \textbf{wxNode}. The user will probably only wish to use the
|
|
|
|
\textbf{GetData} method to retrieve the data; the node may also be deleted.
|
1998-05-20 14:25:30 +00:00
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::Put}\label{wxhashtableput}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
\func{void}{Put}{\param{long}{ key}, \param{wxObject *}{object}}
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
\func{void}{Put}{\param{const char*}{ key}, \param{wxObject *}{object}}
|
1998-05-20 14:25:30 +00:00
|
|
|
|
|
|
|
Inserts data into the hash table, using an integer or string key (depending on which
|
|
|
|
has table constructor was used). The key string is copied and stored by the hash
|
|
|
|
table implementation.
|
|
|
|
|
2004-09-29 11:25:34 +00:00
|
|
|
\membersection{wxHashTable::GetCount}\label{wxhashtablegetcount}
|
2000-01-11 16:27:31 +00:00
|
|
|
|
|
|
|
\constfunc{size\_t}{GetCount}{\void}
|
|
|
|
|
|
|
|
Returns the number of elements in the hash table.
|
|
|
|
|