A hash class. More...

#include "murl_hash.h"

Public Member Functions

 Hash ()
 The default constructor. More...
 
 Hash (const Hash &hash)
 The copy constructor. More...
 
void operator= (const Hash &hash)
 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...
 
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 accessable by a hash value.
This class is based on the NTL Hash container, see http://www.ultimatepp.org

Constructor & Destructor Documentation

◆ Hash() [1/2]

Murl::Hash::Hash ( )
inline

The default constructor.

Create an empty hash object.

◆ Hash() [2/2]

Murl::Hash::Hash ( const Hash hash)
inline

The copy constructor.

Parameters
hashThe hash object to copy.

References Reindex().

Member Function Documentation

◆ operator=()

void Murl::Hash::operator= ( const Hash hash)
inline

The assignment operator.

Parameters
hashThe hash object to copy.

References Reindex().

◆ Reindex()

void Murl::Hash::Reindex ( SInt32  n)
inline

Clear and rebuild the index for a given number of items.

Parameters
nThe number of items to rebuild.

References ClearIndex(), Murl::Array< DataType >::Empty(), and Murl::Util::Fill().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::RebuildHash().

◆ Trim()

Bool Murl::Hash::Trim ( SInt32  n)
inline

Reduce the hash object to a given number of items.

Parameters
nThe new number of items in the hash object, must be smaller than the current item count.
Returns
true if successful.

References Murl::Array< DataType >::GetCount(), MURL_VERIFY, Murl::Array< DataType >::SetCount(), Murl::Array< DataType >::Trim(), and Unlink().

Referenced by Drop(), Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Empty(), and Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Trim().

◆ Drop()

Bool Murl::Hash::Drop ( SInt32  n)
inline

Reduce the hash object by removing a given number of items from the end.

Parameters
nThe number of items to remove from the end.
Returns
true if successful.

References Murl::Array< DataType >::GetCount(), and Trim().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Drop().

◆ Reserve()

void Murl::Hash::Reserve ( SInt32  n)
inline

Reserve storage space.

If the given size is less than the actual size, nothing is done.

Parameters
nThe number of items the underlying storage should hold.

References Reindex(), and Murl::Array< DataType >::Reserve().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Reserve().

◆ Unlink()

Bool Murl::Hash::Unlink ( SInt32  index)
inline

Unlink a given index.

Unlinked items remain in the hash object, but are ignored by any search operations.

Parameters
indexThe index to unlink.
Returns
true if successful.

References Murl::Array< DataType >::GetCount(), IsUnlinked(), and MURL_VERIFY.

Referenced by Set(), SetUn(), Swap(), Trim(), Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Unlink(), and Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::UnlinkKey().

◆ IsUnlinked()

Bool Murl::Hash::IsUnlinked ( SInt32  index) const
inline

Check if the given index is unlinked.

Parameters
indexThe index to check.
Returns
true if the specified item is unlinked.

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::IsUnlinked(), and Unlink().

◆ GetUnlinked()

SInt32Array Murl::Hash::GetUnlinked ( ) const
inline

◆ Set()

void Murl::Hash::Set ( SInt32  index,
UInt32  hash 
)
inline

Replace the index for a specified hash value.

Parameters
indexThe index to set.
hashThe hash value to set.

References Unlink().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Set().

◆ SetUn()

void Murl::Hash::SetUn ( SInt32  index,
UInt32  hash 
)
inline

Replace the hash value at a specified index without consideration of multiple entries per hash value.

Parameters
indexThe index to set.
hashThe hash value to set.

References Unlink().

◆ Add()

void Murl::Hash::Add ( UInt32  hash)
inline

◆ Put()

SInt32 Murl::Hash::Put ( UInt32  hash)
inline

Put a hash value by replacing an unlinked index if present.

Parameters
hashThe hash value to add.
Returns
The index of the hash value or -1 if no unlinked index is available.

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Put().

◆ Insert()

void Murl::Hash::Insert ( SInt32  index,
UInt32  hash 
)
inline

Insert an index for a given hash value.

Parameters
indexThe index to insert.
hashThe hash value to insert.

References ClearIndex(), Murl::Array< DataType >::Insert(), and Reindex().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Insert().

◆ Remove() [1/3]

void Murl::Hash::Remove ( SInt32  index)
inline

Remove the hash value at a given position.

Parameters
indexThe index from where to remove the hash value.

References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Remove().

◆ Remove() [2/3]

void Murl::Hash::Remove ( SInt32  index,
SInt32  count 
)
inline

Remove a number of hash values at a given starting position.

Parameters
indexThe index from where to start removing the hash values.
countThe number of subsequent hash values to remove.

References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().

◆ Remove() [3/3]

void Murl::Hash::Remove ( const SInt32 sortedIndices,
SInt32  count 
)
inline

Remove a number of hash values at given positions.

Parameters
sortedIndicesA pointer to sorted indices where to remove the hash values.
countThe number of hash values to remove, i.e. the number of indices.

References ClearIndex(), Reindex(), and Murl::Array< DataType >::Remove().

◆ Find()

SInt32 Murl::Hash::Find ( UInt32  hash) const
inline

Find the first index of a given hash value.

Parameters
hashThe 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, ObjectArray< KeyType >, HashFunc >::Find(), FindLast(), and Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::UnlinkKey().

◆ FindNext()

SInt32 Murl::Hash::FindNext ( SInt32  index) const
inline

Find the next occurrence of a hash value that is specified by a given index.

Parameters
indexThe 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, ObjectArray< KeyType >, HashFunc >::FindNext(), Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::operator!=(), and Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::UnlinkKey().

◆ FindPrev()

SInt32 Murl::Hash::FindPrev ( SInt32  index) const
inline

Find the previous occurrence of a hash value that is specified by a given index.

Parameters
indexThe 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, ObjectArray< KeyType >, HashFunc >::FindPrev(), and Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::operator!=().

◆ FindLast()

SInt32 Murl::Hash::FindLast ( UInt32  hash) const
inline

Find the last occurrence of a hash value.

Parameters
hashThe 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, ObjectArray< KeyType >, HashFunc >::FindLast().

◆ operator[]()

UInt32 Murl::Hash::operator[] ( SInt32  index) const
inline

Get the hash value for a given index.

If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the hash value to retrieve.
Returns
The hash value of the requested index.

◆ GetCount()

SInt32 Murl::Hash::GetCount ( ) const
inline

Get the number of items.

Returns
The number of items.

References Murl::Array< DataType >::GetCount().

◆ Swap()

void Murl::Hash::Swap ( Hash other)
inline

Exchange the content of the hash object with a given second one.

Parameters
otherThe second hash object.

References Reindex(), Murl::Util::ReleaseArray(), Murl::Util::Swap(), Murl::Array< DataType >::Swap(), and Unlink().

Referenced by Murl::IndexBase< KeyType, ObjectArray< KeyType >, HashFunc >::Swap().


The documentation for this class was generated from the following file:
  • murl_hash.h


Copyright © 2011-2018 Spraylight GmbH.