Adding GetCount() to wxHashTable

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bart A.M. Jourquin
2000-01-11 16:19:35 +00:00
parent 9856788f58
commit 5692876f3b
2 changed files with 16 additions and 0 deletions

View File

@@ -99,6 +99,12 @@ class WXDLLEXPORT wxHashTable: public wxObject
void DeleteContents(bool flag); void DeleteContents(bool flag);
void Clear(void); void Clear(void);
// Returns number of nodes
size_t GetCount() const { return m_count; }
private:
size_t m_count; // number of elements in the hashtable
}; };
#endif #endif

View File

@@ -36,6 +36,7 @@ wxHashTable::wxHashTable (int the_key_type, int size)
n = 0; n = 0;
hash_table = (wxList**) NULL; hash_table = (wxList**) NULL;
Create(the_key_type, size); Create(the_key_type, size);
m_count = 0;
/* /*
n = size; n = size;
current_position = -1; current_position = -1;
@@ -112,6 +113,7 @@ void wxHashTable::Put (long key, long value, wxObject * object)
hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position] = new wxList (wxKEY_INTEGER);
hash_table[position]->Append (value, object); hash_table[position]->Append (value, object);
m_count++;
} }
void wxHashTable::Put (long key, const wxChar *value, wxObject * object) void wxHashTable::Put (long key, const wxChar *value, wxObject * object)
@@ -126,6 +128,7 @@ void wxHashTable::Put (long key, const wxChar *value, wxObject * object)
hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position] = new wxList (wxKEY_INTEGER);
hash_table[position]->Append (value, object); hash_table[position]->Append (value, object);
m_count++;
} }
void wxHashTable::Put (long key, wxObject * object) void wxHashTable::Put (long key, wxObject * object)
@@ -140,6 +143,7 @@ void wxHashTable::Put (long key, wxObject * object)
hash_table[position] = new wxList (wxKEY_INTEGER); hash_table[position] = new wxList (wxKEY_INTEGER);
hash_table[position]->Append (k, object); hash_table[position]->Append (k, object);
m_count++;
} }
void wxHashTable::Put (const wxChar *key, wxObject * object) void wxHashTable::Put (const wxChar *key, wxObject * object)
@@ -150,6 +154,7 @@ void wxHashTable::Put (const wxChar *key, wxObject * object)
hash_table[position] = new wxList (wxKEY_STRING); hash_table[position] = new wxList (wxKEY_STRING);
hash_table[position]->Append (key, object); hash_table[position]->Append (key, object);
m_count++;
} }
wxObject *wxHashTable::Get (long key, long value) const wxObject *wxHashTable::Get (long key, long value) const
@@ -239,6 +244,7 @@ wxObject *wxHashTable::Delete (long key)
{ {
wxObject *data = node->Data (); wxObject *data = node->Data ();
delete node; delete node;
m_count--;
return data; return data;
} }
else else
@@ -258,6 +264,7 @@ wxObject *wxHashTable::Delete (const wxChar *key)
{ {
wxObject *data = node->Data (); wxObject *data = node->Data ();
delete node; delete node;
m_count--;
return data; return data;
} }
else else
@@ -282,6 +289,7 @@ wxObject *wxHashTable::Delete (long key, int value)
{ {
wxObject *data = node->Data (); wxObject *data = node->Data ();
delete node; delete node;
m_count--;
return data; return data;
} }
else else
@@ -301,6 +309,7 @@ wxObject *wxHashTable::Delete (long key, const wxChar *value)
{ {
wxObject *data = node->Data (); wxObject *data = node->Data ();
delete node; delete node;
m_count--;
return data; return data;
} }
else else
@@ -375,5 +384,6 @@ void wxHashTable::Clear (void)
if (hash_table[i]) if (hash_table[i])
hash_table[i]->Clear (); hash_table[i]->Clear ();
} }
m_count = 0;
} }