ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
HashTable< TAllocator, TValueDescriptor, THash, TEqual, THashCaching, TRecycling >::ElementHandle Class Reference

Description:

template<typename TAllocator, typename TValueDescriptor, typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
class alib::containers::HashTable< TAllocator, TValueDescriptor, THash, TEqual, THashCaching, TRecycling >::ElementHandle

A value of this type is returned with methods Extract, which allows removing an element from the hashtable, without deleting its allocated storage and destructing its custom value.

This handle allows writing access to the value of an extracted element. In combination with methods Insert(ElementHandle&) and InsertIfNotExistent(ElementHandle&), this supports changing parts of the element value, including the key-portion with proper re-insertion.

Objects of this type cannot be copied, but just moved.

Definition at line 562 of file hashtable.hpp.

#include <hashtable.hpp>

Collaboration diagram for HashTable< TAllocator, TValueDescriptor, THash, TEqual, THashCaching, TRecycling >::ElementHandle:
[legend]

Public Method Index:

 ElementHandle ()
 Default constructor creating and empty handle.
 
 ElementHandle (ElementHandle &&other)
 
 ElementHandle (ElementHandle &other)=delete
 Deleted copy constructor.
 
 ~ElementHandle ()
 
bool IsEmpty () const
 
KeyTypeKey () const
 
MappedTypeMapped () const
 
ElementHandleoperator= (const ElementHandle &other)=delete
 Deleted copy assignment operator.
 
ElementHandleoperator= (ElementHandle &&other)
 
StoredTypeValue () const
 

Private Field Index:

Elementelement
 The extracted element.
 
HashTabletable
 The table we belong to.
 

Private Method Index:

 ElementHandle (HashTable *pTable, Element *pElement)
 

Field Details:

◆ element

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
Element* element
private

The extracted element.

Definition at line 570 of file hashtable.hpp.

◆ table

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
HashTable* table
private

The table we belong to.

Definition at line 569 of file hashtable.hpp.

Constructor(s) / Destructor Details:

◆ ElementHandle() [1/3]

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
ElementHandle ( HashTable * pTable,
Element * pElement )
inlineprivate

Constructor setting fields table and element.

Parameters
pTableThe table we belong to.
pElementThe extracted element.

Definition at line 575 of file hashtable.hpp.

◆ ElementHandle() [2/3]

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
ElementHandle ( ElementHandle && other)
inline

Move constructor setting the moved object to emtpy.

Parameters
otherThe handle to move.

Definition at line 583 of file hashtable.hpp.

◆ ElementHandle() [3/3]

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
ElementHandle ( )
inline

Default constructor creating and empty handle.

Definition at line 591 of file hashtable.hpp.

◆ ~ElementHandle()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
~ElementHandle ( )
inline

Destructor. If this handle is not empty, the allocated storage of the represented element is added to the list of recyclable objects.

Definition at line 617 of file hashtable.hpp.

Method Details:

◆ IsEmpty()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
bool IsEmpty ( ) const
inline

Determines if this is a "valid" handle.

Returns
Returns true if this objects represents a valid element, false otherwise.

Definition at line 626 of file hashtable.hpp.

◆ Key()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
KeyType & Key ( ) const
inline

Returns a mutable reference to the key-portion of this element's data. Must not be invoked on empty instances.

Returns
Returns a mutable reference to the key-portion of the represented element.

Definition at line 637 of file hashtable.hpp.

◆ Mapped()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
MappedType & Mapped ( ) const
inline

Returns a mutable reference to the mapped-portion of this element's data. Must not be invoked on empty instances.

Returns
Returns a mutable reference to the mapped object.

Definition at line 642 of file hashtable.hpp.

◆ operator=()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
ElementHandle & operator= ( ElementHandle && other)
inline

Move assignment. Disposes any current content, and moves other into this.

Parameters
otherThe handle to move into this object.
Returns
A reference to this.

Definition at line 604 of file hashtable.hpp.

◆ Value()

template<typename TAllocator , typename TValueDescriptor , typename THash = std::hash <typename TValueDescriptor::KeyType>, typename TEqual = std::equal_to<typename TValueDescriptor::KeyType>, lang::Caching THashCaching = lang::Caching::Auto, Recycling TRecycling = Recycling::Private>
StoredType & Value ( ) const
inline

Returns a mutable reference to this element's data. Must not be invoked on empty instances.

Returns
Returns a mutable reference to value of the represented element.

Definition at line 631 of file hashtable.hpp.


The documentation for this class was generated from the following file: