A hash class. More...
#include "murl_hash.h"
Public Member Functions | |
Hash () | |
The default constructor. More... | |
Hash (const Hash &hash) | |
The copy constructor. More... | |
Hash & | operator= (const Hash &hash) |
The assignment operator. More... | |
Hash (Hash &&hash) noexcept | |
The copy constructor. More... | |
Hash & | operator= (Hash &&hash) noexcept |
The assignment operator. More... | |
~Hash () | |
The destructor. | |
void | Clear () |
Clear the hash object. | |
void | ClearIndex () |
Clear the index. | |
void | Reindex (SInt32 n) |
Clear and rebuild the index for a given number of items. More... | |
void | Reindex () |
Clear and rebuild the index. | |
void | Shrink () |
Shrink the hash object so that the underlying storage is only as large as necessary. | |
Bool | Trim (SInt32 n) |
Reduce the hash object to a given number of items. More... | |
Bool | Drop (SInt32 n) |
Reduce the hash object by removing a given number of items from the end. More... | |
void | Reserve (SInt32 n) |
Reserve storage space. More... | |
Bool | Unlink (SInt32 index) |
Unlink a given index. More... | |
Bool | IsUnlinked (SInt32 index) const |
Check if the given index is unlinked. More... | |
Bool | HasUnlinked () const |
Check if the hash has unlinked entries. More... | |
SInt32Array | GetUnlinked () const |
Get an array of unlinked indices. More... | |
void | Set (SInt32 index, UInt32 hash) |
Replace the index for a specified hash value. More... | |
void | SetUn (SInt32 index, UInt32 hash) |
Replace the hash value at a specified index without consideration of multiple entries per hash value. More... | |
void | Add (UInt32 hash) |
Add a hash value. More... | |
SInt32 | Put (UInt32 hash) |
Put a hash value by replacing an unlinked index if present. More... | |
void | Insert (SInt32 index, UInt32 hash) |
Insert an index for a given hash value. More... | |
void | Remove (SInt32 index) |
Remove the hash value at a given position. More... | |
void | Remove (SInt32 index, SInt32 count) |
Remove a number of hash values at a given starting position. More... | |
void | Remove (const SInt32 *sortedIndices, SInt32 count) |
Remove a number of hash values at given positions. More... | |
SInt32 | Find (UInt32 hash) const |
Find the first index of a given hash value. More... | |
SInt32 | FindNext (SInt32 index) const |
Find the next occurrence of a hash value that is specified by a given index. More... | |
SInt32 | FindPrev (SInt32 index) const |
Find the previous occurrence of a hash value that is specified by a given index. More... | |
SInt32 | FindLast (UInt32 hash) const |
Find the last occurrence of a hash value. More... | |
UInt32 | operator[] (SInt32 index) const |
Get the hash value for a given index. More... | |
SInt32 | GetCount () const |
Get the number of items. More... | |
void | Swap (Hash &other) |
Exchange the content of the hash object with a given second one. More... | |
Detailed Description
A hash class.
The hash class stores indices accessible by a hash value.
This class is based on the NTL Hash container, see http://www.ultimatepp.org
Constructor & Destructor Documentation
◆ Hash() [1/3]
|
inline |
The default constructor.
Create an empty hash object.
◆ Hash() [2/3]
|
inline |
◆ Hash() [3/3]
|
inlinenoexcept |
Member Function Documentation
◆ operator=() [1/2]
The assignment operator.
- Parameters
-
hash The hash object to copy.
- Returns
- A reference to this hash object.
References Reindex().
◆ operator=() [2/2]
The assignment operator.
- Parameters
-
hash The hash object to copy.
- Returns
- A reference to this hash object.
References Swap().
◆ Reindex()
|
inline |
Clear and rebuild the index for a given number of items.
- Parameters
-
n The number of items to rebuild.
References ClearIndex(), Murl::Array< DataType >::Empty(), and Murl::Util::Fill().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::RebuildHash().
◆ Trim()
Reduce the hash object to a given number of items.
- Parameters
-
n The new number of items in the hash object, must be smaller than the current item count.
- Returns
- true if successful.
Referenced by Drop(), Murl::IndexBase< KeyType, ArrayType, HashFunc >::Empty(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::Trim().
◆ Drop()
Reduce the hash object by removing a given number of items from the end.
- Parameters
-
n The number of items to remove from the end.
- Returns
- true if successful.
References Murl::Array< DataType >::GetCount(), and Trim().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Drop().
◆ Reserve()
|
inline |
Reserve storage space.
If the given size is less than the actual size, nothing is done.
- Parameters
-
n The number of items the underlying storage should hold.
References Reindex(), and Murl::Array< DataType >::Reserve().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Reserve().
◆ Unlink()
Unlink a given index.
Unlinked items remain in the hash object, but are ignored by any search operations.
- Parameters
-
index The index to unlink.
- Returns
- true if successful.
Referenced by Set(), SetUn(), Murl::IndexBase< KeyType, ArrayType, HashFunc >::Unlink(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::UnlinkKey().
◆ IsUnlinked()
Check if the given index is unlinked.
- Parameters
-
index The index to check.
- Returns
- true if the specified item is unlinked.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::IsUnlinked().
◆ HasUnlinked()
|
inline |
Check if the hash has unlinked entries.
- Returns
- true if there is at least one unlinked entry.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::HasUnlinked(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::Sweep().
◆ GetUnlinked()
|
inline |
Get an array of unlinked indices.
- Returns
- The array of indices.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::GetUnlinked(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::Sweep().
◆ Set()
Replace the index for a specified hash value.
- Parameters
-
index The index to set. hash The hash value to set.
References Unlink().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Set().
◆ SetUn()
Replace the hash value at a specified index without consideration of multiple entries per hash value.
- Parameters
-
index The index to set. hash The hash value to set.
References Unlink().
◆ Add()
|
inline |
Add a hash value.
- Parameters
-
hash The hash value to add.
References Murl::Array< DataType >::Add().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Add().
◆ Put()
Put a hash value by replacing an unlinked index if present.
- Parameters
-
hash The hash value to add.
- Returns
- The index of the hash value or -1 if no unlinked index is available.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Put().
◆ Insert()
Insert an index for a given hash value.
- Parameters
-
index The index to insert. hash The hash value to insert.
References ClearIndex(), Murl::Array< DataType >::Insert(), and Reindex().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Insert().
◆ Remove() [1/3]
|
inline |
Remove the hash value at a given position.
- Parameters
-
index The index from where to remove the hash value.
References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Remove().
◆ Remove() [2/3]
Remove a number of hash values at a given starting position.
- Parameters
-
index The index from where to start removing the hash values. count The number of subsequent hash values to remove.
References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().
◆ Remove() [3/3]
Remove a number of hash values at given positions.
- Parameters
-
sortedIndices A pointer to sorted indices where to remove the hash values. count The number of hash values to remove, i.e. the number of indices.
References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().
◆ Find()
Find the first index of a given hash value.
- Parameters
-
hash The hash value to search for.
- Returns
- The index of the hash value, or -1 if not found.
References Murl::Array< DataType >::GetCount().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::Find(), FindLast(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::UnlinkKey().
◆ FindNext()
Find the next occurrence of a hash value that is specified by a given index.
- Parameters
-
index The index of the hash value to search for.
- Returns
- The index of the next hash value, or -1 if not found.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::FindNext(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::UnlinkKey().
◆ FindPrev()
Find the previous occurrence of a hash value that is specified by a given index.
- Parameters
-
index The index of the hash value to search for.
- Returns
- The index of the previous hash value, or -1 if not found.
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::FindPrev().
◆ FindLast()
Find the last occurrence of a hash value.
- Parameters
-
hash The hash value to search for.
- Returns
- The index of the item, or -1 if not found.
References Find(), and Murl::Array< DataType >::GetCount().
Referenced by Murl::IndexBase< KeyType, ArrayType, HashFunc >::FindLast().
◆ operator[]()
Get the hash value for a given index.
If the index is out of range, the behaviour is undefined.
- Parameters
-
index The index of the hash value to retrieve.
- Returns
- The hash value of the requested index.
◆ GetCount()
|
inline |
Get the number of items.
- Returns
- The number of items.
References Murl::Array< DataType >::GetCount().
◆ Swap()
|
inline |
Exchange the content of the hash object with a given second one.
- Parameters
-
other The second hash object.
References Murl::Array< DataType >::Swap(), and Murl::Util::Swap().
Referenced by Hash(), operator=(), and Murl::IndexBase< KeyType, ArrayType, HashFunc >::Swap().
The documentation for this class was generated from the following file:
- murl_hash.h