#include <HashSet.h>
Inheritance diagram for HashSet:
The main and only difference to the hashtable is that it stores the keys only, not representing a key/value, but a 'key exist?' lookup.
Definition at line 26 of file HashSet.h.
Public Member Functions | |
void | Add (void *key) |
Adds a key to the hash set. | |
bool | Contains (void *key) const |
Returns, if the hash set contains a given key. | |
PointeredList * | GetAll () const |
Returns a new PointeredList of all keys currently in the hash set. | |
long | GetCount () const |
Returns the number of added elements. | |
HashSet (long initSize, int desiredFillRatio) | |
Creates a new hash set with customized settings. | |
HashSet (long initSize) | |
Creates a new hash set with an initial size. | |
HashSet () | |
Creates a new hash set. | |
bool | IsEmpty () const |
Returns whether there are no elements in the hash set. | |
void | Remove (void *key) |
Removes a key from the hash set. | |
void | RemoveAll () |
Removes all keys from the hash set. | |
virtual | ~HashSet () |
Destroys the hash set. | |
Protected Member Functions | |
bool | ContainsKey (void *key) const |
Returns, if the hash table contains a given key. | |
virtual void * | CreateKey (void *key) const |
Creates the key object that shall be stored in the key buckets. | |
void | Delete (void *key) |
Removes a key/value pair from the hash table. | |
void | DeleteAll () |
Removes all key/value pairs from the hash table. | |
virtual void | DestroyKey (void *key) const |
Disposes a key created by the CreateKey method. | |
virtual bool | Equals (void *key1, void *key2) const |
Checks, if to keys equal each other. | |
Void * | Get (void *key) const |
Returns the value of a key/value pair by its key. | |
int | GetDesiredFillRatio () const |
Returns the fill ratio after a hash table resize. | |
int | GetFillRatio () const |
Returns the current fill ratio. | |
PointeredList * | GetKeys () const |
Returns a new PointeredList of all keys currently in the hash table. | |
long | GetSize () const |
Returns the number of buckets currently used. | |
PointeredList * | GetValues () const |
Returns a new PointeredList of all values currently in the hash table. | |
virtual unsigned long | HashCode (void *key) const |
Returns the hash code of the key. | |
void | Set (void *key, Void *Value) |
Sets a key/value pair into the hash table. | |
Void * | Unset (void *key) |
Removes a key/value pair from the hash table. | |
void | UnsetAll () |
Removes all key/value pairs from the hash table. | |
Protected Attributes | |
PointeredList ** | KeyBuckets |
The array of key buckets. | |
long | Size |
The number of buckets currently used. | |
PointeredList ** | ValueBuckets |
The array of value buckets. |
|
Creates a new hash set.
|
|
Creates a new hash set with an initial size.
|
|
Creates a new hash set with customized settings.
|
|
Destroys the hash set. The memory of the keys is not freed, since it was not acquired, |
|
Adds a key to the hash set. Afterwards, the method checks if the hash set has to be resized.
|
|
Returns, if the hash set contains a given key.
|
|
Returns, if the hash table contains a given key.
|
|
Creates the key object that shall be stored in the key buckets. The method receives a key and e.g. creates a clone, or uses the key directly, if this is possible. The Equals and HashCode method must return the same values when using the original key and the one returned by this method. The DestroyKey method disposes this key again. In the HashMap class, the key is returned directly.
Reimplemented in StringKeyHashMap< Void >. |
|
Removes a key/value pair from the hash table. The memory of the key is not freed, since it was not acquired, but the memory of the value is freed.
|
|
Removes all key/value pairs from the hash table. The memory of the keys is not freed, since it was not acquired, but the memory of the values is freed. |
|
Disposes a key created by the CreateKey method. This can be done by freeing the memory, if the key was cloned, or by simply doing nothing, if the user's key was directly used. This method should do the opposite of the CreateKey method. In the HashMap class, this method does nothing, since the key was directly used.
Reimplemented in StringKeyHashMap< Void >. |
|
Checks, if to keys equal each other. In the HashMap class, this is true, if they point to the same memory.
Reimplemented in StringKeyHashMap< Void >, and ICStringKeyHashMap< Void >. |
|
Returns the value of a key/value pair by its key.
|
|
Returns a new PointeredList of all keys currently in the hash set.
|
|
Returns the number of added elements.
Reimplemented from HashMap< Void >. |
|
Returns the fill ratio after a hash table resize.
|
|
Returns the current fill ratio. This is the ratio between the used hash table cells (Count), and the reserved cells (Size).
|
|
Returns a new PointeredList of all keys currently in the hash table.
|
|
Returns the number of buckets currently used.
|
|
Returns a new PointeredList of all values currently in the hash table.
|
|
Returns the hash code of the key. This is a value that has to be constant for the same key all the time, needs not to be injective, and should distribute the keys quite good.
Reimplemented in IntKeyHashMap< Void >, StringKeyHashMap< Void >, and ICStringKeyHashMap< Void >. |
|
Returns whether there are no elements in the hash set.
Reimplemented from HashMap< Void >. |
|
Removes a key from the hash set. Afterwards, the method checks if the hash set has to be resized. The memory of the key is not freed.
|
|
Removes all keys from the hash set. Afterwards, the method checks if the hash set has to be resized. The memory of the key is not freed. |
|
Sets a key/value pair into the hash table. Afterwards, the method checks if the hash table has to be resized. If the key existed, the old value is replaced, and its memory is freed.
|
|
Removes a key/value pair from the hash table. Afterwards, the method checks if the hash table has to be resized. Both the memory of the key and the memory of the value are not freed, but the value is returned.
|
|
Removes all key/value pairs from the hash table. Afterwards, the method checks if the hash table has to be resized. Both the memory of the keys and the memory of the values are not freed.
|
|
The array of key buckets.
|
|
The number of buckets currently used.
|
|
The array of value buckets.
|