Web Analytics Made Easy - Statcounter
Skip to content

Class SBCReferenceHashMap#

ClassList > SBCReferenceHashMap

Inherits the following classes: SBCContainerHashMap

Public Functions inherited from SBCContainerHashMap#

See SBCContainerHashMap

Type Name
SBCContainerHashMap (unsigned int nElements=0)
Creates a new hash map.
SBCContainerHashMap (const SBCContainerHashMap & hashMap)
Copy constructor.
SBCContainerHashMap (SBCContainerHashMap && hashMap) noexcept
Move constructor.
SBCContainerHashMap (std::initializer_list< std::pair< KeyType, ValueType > > init)
Creates a new hash map from the given initializer list.
iterator begin ()
Returns an iterator that points to the beginning of the hash map.
const_iterator begin () const
Returns an iterator that points to the beginning of the hash map.
void clear ()
Erases all entries in the hash map.
bool empty () noexcept const
Returns true when the hash map contains no entry.
iterator end ()
Returns an iterator that points to the end of the hash map.
const_iterator end () const
Returns an iterator that points to the end of the hash map.
bool erase (const KeyType & key)
Attempts to erase an entry with a specific key and returnstrue if successful.
iterator find (const KeyType & key)
Finds a key in the hash map.
const_iterator find (const KeyType & key) const
Finds a key in the hash map.
unsigned int getMemoryFootprint () const
Returns the memory footprint of the hash map.
bool getValue (const KeyType & key, ValueType & value) const
Returns true if the__key has an associated value and puts it in the__value , else returnsfalse .
std::optional< ValueType > getValue (const KeyType & key) const
Returns the value associated to the key if found.
bool hasValue (const KeyType & key) const
Returns true if the__key has an associated value.
SBHashMapEntry< KeyType, ValueType > * insert (const KeyType & key, const ValueType & value)
Inserts an element in the hash map.
SBCContainerHashMap & operator= (const SBCContainerHashMap & hashMap)
Copy assignment.
SBCContainerHashMap & operator= (SBCContainerHashMap && hashMap)
Move assignment.
ValueType & operator[] (const KeyType & key)
Returns a reference to the value mapped to the key, which is inserted if necessary.
unsigned int size () noexcept const
The number of entries in the hash map.
std::map< KeyType, ValueType > toStdMap () const
Returns an std::map containing the same (key, value) pairs.
std::unordered_map< KeyType, ValueType > toStdUnorderedMap () const
Returns an std::unordered_map containing the same (key, value) pairs.
virtual ~SBCContainerHashMap ()
Deletes the hash map.

Protected Attributes inherited from SBCContainerHashMap#

See SBCContainerHashMap

Type Name
SBCContainerVector< SBCContainerHashMapEntry< KeyType, ValueType > * > * hashMap
The hash table.
unsigned int numberOfEntries
The number of entries in the hash map.

Protected Functions#

Type Name
SBCReferenceHashMap (unsigned int nElements=0)
Creates a new hash map.
bool eraseReferenceTarget (SBCReferenceTarget * referenceTarget)
Attempts to erase an entry with a specific reference and returnstrue if successful.
bool eraseReferenceToTarget (SBCReferenceToTarget * referenceToTarget)
Attempts to erase an entry with a specific reference and returnstrue if successful.
unsigned int getValue (SBCReferenceToTarget * referenceToTarget) const
Returns the value associated to the reference.
bool getValue (SBCReferenceToTarget * referenceToTarget, unsigned int & value) const
Returns the value associated to the reference.
unsigned int getValue (SBCReferenceTarget * referenceTarget) const
Returns the value associated to the reference.
bool getValue (SBCReferenceTarget * referenceTarget, unsigned int & value) const
Returns the value associated to the reference.
bool hasValue (SBCReferenceToTarget * referenceToTarget) const
Returns true if the__reference has an associated value.
bool hasValue (SBCReferenceTarget * referenceTarget) const
Returns true if the__reference has an associated value.
virtual ~SBCReferenceHashMap ()
Destructor for SBCReferenceHashMap.

Protected Functions Documentation#

function SBCReferenceHashMap#

Creates a new hash map.

SBCReferenceHashMap::SBCReferenceHashMap (
    unsigned int nElements=0
) 

Constructs a new SBCReferenceHashMap.

Parameters:

  • nElements The initial number of elements (capacity) for the hash map.

function eraseReferenceTarget#

Attempts to erase an entry with a specific reference and returnstrue if successful.

bool SBCReferenceHashMap::eraseReferenceTarget (
    SBCReferenceTarget * referenceTarget
) 

Erases the entry for the specified reference target.

Parameters:

  • target Pointer to the reference target object to erase.

Returns:

true if an entry was erased, false otherwise.


function eraseReferenceToTarget#

Attempts to erase an entry with a specific reference and returnstrue if successful.

bool SBCReferenceHashMap::eraseReferenceToTarget (
    SBCReferenceToTarget * referenceToTarget
) 

Erases the entry for the specified reference-to-target.

Parameters:

  • referenceToTarget Pointer to the reference-to-target object to erase.

Returns:

true if an entry was erased, false otherwise.


function getValue [1/4]#

Returns the value associated to the reference.

unsigned int SBCReferenceHashMap::getValue (
    SBCReferenceToTarget * referenceToTarget
) const

Retrieves the value associated with the given reference-to-target.

Parameters:

  • referenceToTarget Pointer to the reference-to-target object.

Returns:

The associated unsigned integer value, or an invalid sentinel if not found.


function getValue [2/4]#

Returns the value associated to the reference.

bool SBCReferenceHashMap::getValue (
    SBCReferenceToTarget * referenceToTarget,
    unsigned int & value
) const

Retrieves the value associated with the given reference-to-target and stores it in the output parameter.

Parameters:

  • referenceToTarget Pointer to the reference-to-target object.
  • referenceToTargetIndex Output parameter that receives the associated value if found.

Returns:

true if the value was found, false otherwise.


function getValue [3/4]#

Returns the value associated to the reference.

unsigned int SBCReferenceHashMap::getValue (
    SBCReferenceTarget * referenceTarget
) const

Retrieves the value associated with the given reference target.

Parameters:

  • target Pointer to the reference target object.

Returns:

The associated unsigned integer value, or an invalid sentinel if not found.


function getValue [4/4]#

Returns the value associated to the reference.

bool SBCReferenceHashMap::getValue (
    SBCReferenceTarget * referenceTarget,
    unsigned int & value
) const

Retrieves the value associated with the given reference target and stores it in the output parameter.

Parameters:

  • target Pointer to the reference target object.
  • referenceToTargetIndex Output parameter that receives the associated value if found.

Returns:

true if a value was found, false otherwise.


function hasValue [1/2]#

Returns true if the__reference has an associated value.

bool SBCReferenceHashMap::hasValue (
    SBCReferenceToTarget * referenceToTarget
) const

Checks whether the given reference-to-target has an associated value.

Parameters:

  • referenceToTarget Pointer to the reference-to-target object.

Returns:

true if an associated value exists, false otherwise.


function hasValue [2/2]#

Returns true if the__reference has an associated value.

bool SBCReferenceHashMap::hasValue (
    SBCReferenceTarget * referenceTarget
) const

Checks whether the given reference target has an associated value.

Parameters:

  • target Pointer to the reference target object.

Returns:

true if an associated value exists, false otherwise.


function ~SBCReferenceHashMap#

Destructor for SBCReferenceHashMap.

virtual SBCReferenceHashMap::~SBCReferenceHashMap ()