ORIGINAL
Loading...
Searching...
No Matches
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode Class Referencefinal

Internal node type for hash table storage. More...

#include <hashTable.h>

Inheritance diagram for original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode:
Inheritance graph
Collaboration diagram for original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode:
Collaboration graph

Public Member Functions

 hashNode (const K_TYPE &key=K_TYPE{}, const V_TYPE &value=V_TYPE{}, hashNode *next=nullptr)
 Constructs a new hash node.
 
 hashNode (const hashNode &other)
 Copy constructor.
 
hashNodeoperator= (const hashNode &other)
 Copy assignment operator.
 
couple< const K_TYPE, V_TYPE > & getVal () override
 Gets key-value pair (non-const)
 
const couple< const K_TYPE, V_TYPE > & getVal () const override
 Gets key-value pair (const)
 
const K_TYPE & getKey () const
 Gets the key (const)
 
const V_TYPE & getValue () const
 Gets the value (const)
 
V_TYPE & getValue ()
 Gets the value (non-const)
 
void setVal (couple< const K_TYPE, V_TYPE > data) override
 Not supported (throws unSupportedMethodError)
 
void setValue (const V_TYPE &value)
 Sets a new value.
 
hashNodegetPPrev () const override
 Not supported (throws unSupportedMethodError)
 
hashNodegetPNext () const override
 Gets next node in chain.
 
void setPNext (hashNode *new_next)
 Sets next node in chain.
 
- Public Member Functions inherited from original::wrapper< couple< const K_TYPE, V_TYPE > >
 ~wrapper () override=default
 Destructor for the wrapper class.
 
std::string className () const override
 Provides class identifier for diagnostics. See original::printable::className()
 
std::string toString (bool enter) const override
 Generates formatted diagnostic string. See original::printable::toString()
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const char * toCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE>
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE>
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatString (TYPE *const &ptr) -> std::string
 

Static Public Member Functions

static void connect (hashNode *prev, hashNode *next)
 Connects two nodes in chain.
 
- Static Public Member Functions inherited from original::printable
template<typename TYPE>
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion.
 
template<typename TYPE>
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting.
 
template<typename TYPE>
static const char * formatCString (const TYPE &t)
 C-string cache for temporary usage.
 
template<typename TYPE>
static std::string formatEnum (const TYPE &t)
 Enum formatting utility.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 

Detailed Description

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<K_TYPE>, typename HASH = hash<K_TYPE>>
class original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode

Internal node type for hash table storage.

Wraps key-value pairs and maintains chain links for separate chaining. Each node contains:

The class provides:

  • Key/value access methods
  • Chain manipulation methods
  • Proper memory management through wrapper interface

Constructor & Destructor Documentation

◆ hashNode() [1/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::hashNode ( const K_TYPE & key = K_TYPE{},
const V_TYPE & value = V_TYPE{},
hashNode * next = nullptr )
explicit

Constructs a new hash node.

Parameters
keyKey to store (const reference)
valueValue to associate
nextNext node in chain (nullptr if end of chain)

◆ hashNode() [2/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::hashNode ( const hashNode & other)

Copy constructor.

Parameters
otherNode to copy from

Member Function Documentation

◆ connect()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
void original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::connect ( hashNode * prev,
hashNode * next )
static

Connects two nodes in chain.

Parameters
prevPrevious node in chain
nextNext node in chain
Note
If prev is nullptr, does nothing

◆ getKey()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
const K_TYPE & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getKey ( ) const

Gets the key (const)

Returns
Const reference to the key

◆ getPNext()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode * original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getPNext ( ) const
overridevirtual

Gets next node in chain.

Returns
Pointer to next node (nullptr if end of chain)

Implements original::wrapper< couple< const K_TYPE, V_TYPE > >.

◆ getPPrev()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode * original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getPPrev ( ) const
overridevirtual

◆ getVal() [1/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
const original::couple< const K_TYPE, V_TYPE > & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getVal ( ) const
overridevirtual

Gets key-value pair (const)

Returns
Const reference to the contained pair

Implements original::wrapper< couple< const K_TYPE, V_TYPE > >.

◆ getVal() [2/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::couple< const K_TYPE, V_TYPE > & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getVal ( )
overridevirtual

Gets key-value pair (non-const)

Returns
Reference to the contained pair

Implements original::wrapper< couple< const K_TYPE, V_TYPE > >.

◆ getValue() [1/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
V_TYPE & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getValue ( )

Gets the value (non-const)

Returns
Reference to the value

◆ getValue() [2/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
const V_TYPE & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::getValue ( ) const

Gets the value (const)

Returns
Const reference to the value

◆ operator=()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode & original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::operator= ( const hashNode & other)

Copy assignment operator.

Parameters
otherNode to copy from
Returns
Reference to this node

◆ setPNext()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
void original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::setPNext ( hashNode * new_next)

Sets next node in chain.

Parameters
new_nextNew next node to set

◆ setVal()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
void original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::setVal ( couple< const K_TYPE, V_TYPE > data)
overridevirtual

◆ setValue()

template<typename K_TYPE, typename V_TYPE, typename ALLOC, typename HASH>
void original::hashTable< K_TYPE, V_TYPE, ALLOC, HASH >::hashNode::setValue ( const V_TYPE & value)

Sets a new value.

Parameters
valueNew value to set

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