AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::experimental::axom_map::Bucket< Key, T > Class Template Reference

Bucket is the implementation of a bucket for this Map with chaining. It's a singly-linked list, and supports search, insertion, and removal. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/latest/src/axom/core/Map.hpp>

Public Member Functions

Bucket Construction
 Bucket ()
 Default constructor so new Buckets just construct into nothing. Can likely just be removed. More...
 
 Bucket (IndexType len)
 Basic constructor, creates singly-linked list with provided size. More...
 
void init (IndexType len)
 If a Bucket instance is created with the default contructor, this is used to initialize and allocate all the member variables. More...
 
Bucket Methods
axom_map::Pair< Key, T > insert_no_update (const Key &key, const T &value)
 Inserts a given key-value pair into the linked list if an item with given key does not already exist. Fails if list is full or item with given key already exists. More...
 
axom_map::Pair< Key, T > insert_update (const Key &key, const T &value)
 Inserts a given key-value pair into the linked list if an item with given key does not already exist, and updates the item's current value with the supplied one if item already exists. Fails if list is full. More...
 
bool remove (const Key &key)
 Removes item with the given key from the linked list, if item exists. Relinks accordingly. More...
 
axom_map::Node< Key, T > & find (const Key &key)
 Returns pointer to node containing key-value pair matching provided key, if possible. More...
 
int get_capacity () const
 Returns maximum number of items that can be stored in this Bucket instance. More...
 
int get_size () const
 Returns current number of items in this Bucket instance. More...
 

Public Attributes

axom_map::Node< Key, T > * m_list
 
axom_map::Node< Key, T > m_end
 
IndexType m_head
 
IndexType m_free
 
IndexType m_capacity
 
IndexType m_size
 

Detailed Description

template<typename Key, typename T>
class axom::experimental::axom_map::Bucket< Key, T >

Bucket is the implementation of a bucket for this Map with chaining. It's a singly-linked list, and supports search, insertion, and removal.

Template Parameters
Keythe type of the keys stored in each Node in the list. \tparapm T the type of the values stored in each Node in the list.

Constructor & Destructor Documentation

◆ Bucket() [1/2]

template<typename Key , typename T >
axom::experimental::axom_map::Bucket< Key, T >::Bucket ( )
inline

Default constructor so new Buckets just construct into nothing. Can likely just be removed.

◆ Bucket() [2/2]

template<typename Key , typename T >
axom::experimental::axom_map::Bucket< Key, T >::Bucket ( IndexType  len)
inline

Basic constructor, creates singly-linked list with provided size.

Parameters
[in]lenthe number of items this Bucket instance needs to be able to store.
Precondition
len > 0

References axom::experimental::axom_map::Bucket< Key, T >::init().

Member Function Documentation

◆ init()

template<typename Key , typename T >
void axom::experimental::axom_map::Bucket< Key, T >::init ( IndexType  len)
inline

If a Bucket instance is created with the default contructor, this is used to initialize and allocate all the member variables.

Parameters
[in]lenthe number of items this Bucket instance needs to be able to store.
Precondition
len > 0

References axom::experimental::axom_map::Bucket< Key, T >::m_capacity, axom::experimental::axom_map::Bucket< Key, T >::m_end, axom::experimental::axom_map::Bucket< Key, T >::m_free, axom::experimental::axom_map::Bucket< Key, T >::m_head, axom::experimental::axom_map::Bucket< Key, T >::m_list, and axom::experimental::axom_map::Bucket< Key, T >::m_size.

◆ insert_no_update()

template<typename Key , typename T >
axom_map::Pair<Key, T> axom::experimental::axom_map::Bucket< Key, T >::insert_no_update ( const Key &  key,
const T &  value 
)
inline

Inserts a given key-value pair into the linked list if an item with given key does not already exist. Fails if list is full or item with given key already exists.

Parameters
[in]keythe key of the key-value pair to be inserted.
[in]valuethe value of the key-value pair to be inserted.
Returns
Returns a Pair object, with the first element being a pointer to the inserted node and the second element being boolean value true if successful. If insertion fails, the bool is set to False, and the node pointed to is the end node if the list was full, or the item occupying the queried slot if an item with the given key already existed.

References axom::experimental::axom_map::Bucket< Key, T >::m_end, axom::experimental::axom_map::Bucket< Key, T >::m_free, axom::experimental::axom_map::Bucket< Key, T >::m_head, axom::experimental::axom_map::Bucket< Key, T >::m_list, and axom::experimental::axom_map::Bucket< Key, T >::m_size.

◆ insert_update()

template<typename Key , typename T >
axom_map::Pair<Key, T> axom::experimental::axom_map::Bucket< Key, T >::insert_update ( const Key &  key,
const T &  value 
)
inline

Inserts a given key-value pair into the linked list if an item with given key does not already exist, and updates the item's current value with the supplied one if item already exists. Fails if list is full.

Parameters
[in]keythe key of the key-value pair to be inserted.
[in]valuethe value of the key-value pair to be inserted.
Returns
Returns a Pair object, with the first element being a pointer to the inserted node and the second element being boolean value true if successful. If insertion fails, or assignment was performed, the bool is set to False. If assignment occured, the node pointed to is the item corresponding to the supplied key. Otherwise, if insertion and assignment failed, the node pointed to is the end node.

References axom::experimental::axom_map::Bucket< Key, T >::m_end, axom::experimental::axom_map::Bucket< Key, T >::m_free, axom::experimental::axom_map::Bucket< Key, T >::m_head, axom::experimental::axom_map::Bucket< Key, T >::m_list, and axom::experimental::axom_map::Bucket< Key, T >::m_size.

◆ remove()

template<typename Key , typename T >
bool axom::experimental::axom_map::Bucket< Key, T >::remove ( const Key &  key)
inline

Removes item with the given key from the linked list, if item exists. Relinks accordingly.

Parameters
[in]keythe key of the item to be found and removed.
Returns
Returns true if item was found and removed, false otherwise.

References axom::experimental::axom_map::Bucket< Key, T >::m_free, axom::experimental::axom_map::Bucket< Key, T >::m_head, axom::experimental::axom_map::Bucket< Key, T >::m_list, and axom::experimental::axom_map::Bucket< Key, T >::m_size.

◆ find()

template<typename Key , typename T >
axom_map::Node<Key, T>& axom::experimental::axom_map::Bucket< Key, T >::find ( const Key &  key)
inline

Returns pointer to node containing key-value pair matching provided key, if possible.

Parameters
[in]keythe key of the item to be searched for.
Returns
Returns pointer to the requested node if possible, and to special end node otherwise.

References axom::experimental::axom_map::Bucket< Key, T >::m_end, axom::experimental::axom_map::Bucket< Key, T >::m_head, and axom::experimental::axom_map::Bucket< Key, T >::m_list.

◆ get_capacity()

template<typename Key , typename T >
int axom::experimental::axom_map::Bucket< Key, T >::get_capacity ( ) const
inline

Returns maximum number of items that can be stored in this Bucket instance.

Returns
Returns maximum number of items that can be stored in this Bucket instance.

References axom::experimental::axom_map::Bucket< Key, T >::m_capacity.

◆ get_size()

template<typename Key , typename T >
int axom::experimental::axom_map::Bucket< Key, T >::get_size ( ) const
inline

Returns current number of items in this Bucket instance.

Returns
Returns current number of items in this Bucket instance.

References axom::experimental::axom_map::Bucket< Key, T >::m_size.

Member Data Documentation

◆ m_list

template<typename Key , typename T >
axom_map::Node<Key, T>* axom::experimental::axom_map::Bucket< Key, T >::m_list

◆ m_end

template<typename Key , typename T >
axom_map::Node<Key, T> axom::experimental::axom_map::Bucket< Key, T >::m_end

◆ m_head

template<typename Key , typename T >
IndexType axom::experimental::axom_map::Bucket< Key, T >::m_head

◆ m_free

template<typename Key , typename T >
IndexType axom::experimental::axom_map::Bucket< Key, T >::m_free

◆ m_capacity

template<typename Key , typename T >
IndexType axom::experimental::axom_map::Bucket< Key, T >::m_capacity

◆ m_size

template<typename Key , typename T >
IndexType axom::experimental::axom_map::Bucket< Key, T >::m_size

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