ORIGINAL
Loading...
Searching...
No Matches
original::map< K_TYPE, V_TYPE, ALLOC > Class Template Referenceabstract

Abstract base class for key-value mapping containers. More...

#include <map.h>

Inheritance diagram for original::map< K_TYPE, V_TYPE, ALLOC >:
Inheritance graph
Collaboration diagram for original::map< K_TYPE, V_TYPE, ALLOC >:
Collaboration graph

Public Member Functions

virtual bool add (const K_TYPE &k, const V_TYPE &v)=0
 Adds a new key-value pair to the map.
 
virtual bool remove (const K_TYPE &k)=0
 Removes a key-value pair from the map.
 
virtual bool containsKey (const K_TYPE &k) const =0
 Checks if a key exists in the map.
 
virtual V_TYPE get (const K_TYPE &k) const =0
 Gets the value associated with a key.
 
virtual bool update (const K_TYPE &key, const V_TYPE &value)=0
 Updates the value for an existing key.
 
virtual const V_TYPE & operator[] (const K_TYPE &k) const =0
 Const access to mapped values.
 
virtual V_TYPE & operator[] (const K_TYPE &k)=0
 Non-const access to mapped values.
 
 ~map () override
 Virtual destructor.
 

Protected Member Functions

 map (ALLOC alloc=ALLOC{})
 Constructs a map with the specified allocator.
 

Detailed Description

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
class original::map< K_TYPE, V_TYPE, ALLOC >

Abstract base class for key-value mapping containers.

Template Parameters
K_TYPEThe key type (must support equality comparison and hashing)
V_TYPEThe value type to store
ALLOCAllocator type for memory management (default: allocator)

This abstract class defines the common interface for all map implementations in the framework. Concrete implementations should inherit from this class and provide the actual storage mechanism.

The map guarantees:

  • Unique keys (no duplicates)
  • Efficient value lookup by key
  • Type-safe operations
  • Exception safety (throws noElementError for invalid access)
Note
This class is not meant to be instantiated directly - use concrete implementations like hashMap or treeMap instead.

Constructor & Destructor Documentation

◆ map()

template<typename K_TYPE, typename V_TYPE, typename ALLOC>
original::map< K_TYPE, V_TYPE, ALLOC >::map ( ALLOC alloc = ALLOC{})
explicitprotected

Constructs a map with the specified allocator.

Parameters
allocAllocator to use for memory management

Member Function Documentation

◆ add()

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual bool original::map< K_TYPE, V_TYPE, ALLOC >::add ( const K_TYPE & k,
const V_TYPE & v )
pure virtual

Adds a new key-value pair to the map.

Parameters
kThe key to add
vThe value to associate with the key
Returns
true if the pair was added successfully, false if the key already exists

◆ containsKey()

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual bool original::map< K_TYPE, V_TYPE, ALLOC >::containsKey ( const K_TYPE & k) const
nodiscardpure virtual

Checks if a key exists in the map.

Parameters
kThe key to check
Returns
true if the key exists, false otherwise

◆ get()

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual V_TYPE original::map< K_TYPE, V_TYPE, ALLOC >::get ( const K_TYPE & k) const
pure virtual

Gets the value associated with a key.

Parameters
kThe key to look up
Returns
The associated value
Exceptions
noElementErrorif the key doesn't exist

◆ operator[]() [1/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual const V_TYPE & original::map< K_TYPE, V_TYPE, ALLOC >::operator[] ( const K_TYPE & k) const
pure virtual

Const access to mapped values.

Parameters
kThe key to access
Returns
const reference to the mapped value
Exceptions
noElementErrorif the key doesn't exist
Note
This version is for read-only access and will not modify the map

◆ operator[]() [2/2]

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual V_TYPE & original::map< K_TYPE, V_TYPE, ALLOC >::operator[] ( const K_TYPE & k)
pure virtual

Non-const access to mapped values.

Parameters
kThe key to access
Returns
reference to the mapped value
Note
If the key doesn't exist, inserts a new key-value pair with:
  • The specified key
  • A default-constructed value Then returns reference to the new value

◆ remove()

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual bool original::map< K_TYPE, V_TYPE, ALLOC >::remove ( const K_TYPE & k)
pure virtual

Removes a key-value pair from the map.

Parameters
kThe key to remove
Returns
true if the pair was removed, false if the key didn't exist

◆ update()

template<typename K_TYPE, typename V_TYPE, typename ALLOC = allocator<couple<const K_TYPE, V_TYPE>>>
virtual bool original::map< K_TYPE, V_TYPE, ALLOC >::update ( const K_TYPE & key,
const V_TYPE & value )
pure virtual

Updates the value for an existing key.

Parameters
keyThe key to update
valueThe new value to associate with the key
Returns
true if the update succeeded (key existed), false if the key didn't exist
Note
Unlike operator[], this will not insert new keys

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