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 move constructor. More... | |
| Hash & | operator= (Hash &&hash) noexcept |
| The move 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]
| Murl::Hash::Hash | ( | ) |
The default constructor.
Create an empty hash object.
◆ Hash() [2/3]
| Murl::Hash::Hash | ( | const Hash & | hash | ) |
The copy constructor.
- Parameters
-
hash The hash object to copy.
◆ Hash() [3/3]
|
noexcept |
The move constructor.
- Parameters
-
hash The hash object to move.
Member Function Documentation
◆ operator=() [1/2]
The assignment operator.
- Parameters
-
hash The hash object to copy.
- Returns
- A reference to this hash object.
◆ operator=() [2/2]
The move operator.
- Parameters
-
hash The hash object to move.
- Returns
- A reference to this hash object.
◆ Reindex()
| void Murl::Hash::Reindex | ( | SInt32 | n | ) |
Clear and rebuild the index for a given number of items.
- Parameters
-
n The number of items to rebuild.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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 Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Empty(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Drop().
◆ Reserve()
| void Murl::Hash::Reserve | ( | SInt32 | n | ) |
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.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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 Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Unlink(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::IsUnlinked().
◆ HasUnlinked()
| Bool Murl::Hash::HasUnlinked | ( | ) | const |
Check if the hash has unlinked entries.
- Returns
- true if there is at least one unlinked entry.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::HasUnlinked(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Sweep().
◆ GetUnlinked()
| SInt32Array Murl::Hash::GetUnlinked | ( | ) | const |
Get an array of unlinked indices.
- Returns
- The array of indices.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::GetUnlinked(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Sweep().
◆ Set()
Replace the index for a specified hash value.
- Parameters
-
index The index to set. hash The hash value to set.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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.
◆ Add()
| void Murl::Hash::Add | ( | UInt32 | hash | ) |
Add a hash value.
- Parameters
-
hash The hash value to add.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Put().
◆ Insert()
Insert an index for a given hash value.
- Parameters
-
index The index to insert. hash The hash value to insert.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Insert().
◆ Remove() [1/3]
| void Murl::Hash::Remove | ( | SInt32 | index | ) |
Remove the hash value at a given position.
- Parameters
-
index The index from where to remove the hash value.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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.
◆ 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.
◆ 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.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Find(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::FindNext(), and Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, 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()
| SInt32 Murl::Hash::GetCount | ( | ) | const |
Get the number of items.
- Returns
- The number of items.
◆ Swap()
| void Murl::Hash::Swap | ( | Hash & | other | ) |
Exchange the content of the hash object with a given second one.
- Parameters
-
other The second hash object.
Referenced by Murl::IndexBase< Murl::Video::IFrameBuffer *, Array< Murl::Video::IFrameBuffer * >, HashFunc >::Swap().
The documentation for this class was generated from the following file:
- murl_hash.h