Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

ogdf::UsuallySmallMap< Key2, Value, array_max > Struct Template Reference

A wrapper around std::map that uses a constant-size array (or only a single value) plus linear search until the map grows too big. More...

#include <ogdf/cluster/sync_plan/basic/RegisteredMultiArray.h>

Public Types

using ValueArrayType = std::array< ValuePairType, array_max >
 
using ValueMapType = std::unordered_map< Key2, Value >
 
using ValuePairType = std::pair< Key2, Value >
 

Public Member Functions

 UsuallySmallMap ()=default
 
 UsuallySmallMap (const UsuallySmallMap &copy)
 
 UsuallySmallMap (UsuallySmallMap &&move) noexcept
 
 ~UsuallySmallMap ()
 
bool contains (const Key2 &key) const
 
bool empty () const
 
Value & get_or_create (const Key2 &key, const Value &def=Value())
 
Value & get_or_raise (const Key2 &key) const
 
ValueArrayTypegetValueArray () const
 
ValueMapTypegetValueMap () const
 
ValuePairTypegetValueScalar () const
 
UsuallySmallMapoperator= (UsuallySmallMap copy_by_value) noexcept
 Assign this UsuallySmallMap to be a copy of copy_by_value. More...
 
size_t size () const
 
void unset (const Key2 &key)
 
bool usesMap () const
 

Public Attributes

uint8_t m_size = 0
 
void * m_value = nullptr
 

Friends

void swap (UsuallySmallMap &first, UsuallySmallMap &second) noexcept
 

Detailed Description

template<typename Key2, typename Value, int array_max>
struct ogdf::UsuallySmallMap< Key2, Value, array_max >

A wrapper around std::map that uses a constant-size array (or only a single value) plus linear search until the map grows too big.

Automatically grows from storing a single value, over using an std::array of at most array_max values, to using an unbounded std::map. This is used for managing the second dimension of RegisteredMultiArray for a single value in the first dimension.

Definition at line 52 of file RegisteredMultiArray.h.

Member Typedef Documentation

◆ ValueArrayType

template<typename Key2 , typename Value , int array_max>
using ogdf::UsuallySmallMap< Key2, Value, array_max >::ValueArrayType = std::array<ValuePairType, array_max>

Definition at line 54 of file RegisteredMultiArray.h.

◆ ValueMapType

template<typename Key2 , typename Value , int array_max>
using ogdf::UsuallySmallMap< Key2, Value, array_max >::ValueMapType = std::unordered_map<Key2, Value>

Definition at line 55 of file RegisteredMultiArray.h.

◆ ValuePairType

template<typename Key2 , typename Value , int array_max>
using ogdf::UsuallySmallMap< Key2, Value, array_max >::ValuePairType = std::pair<Key2, Value>

Definition at line 53 of file RegisteredMultiArray.h.

Constructor & Destructor Documentation

◆ UsuallySmallMap() [1/3]

template<typename Key2 , typename Value , int array_max>
ogdf::UsuallySmallMap< Key2, Value, array_max >::UsuallySmallMap ( )
default

◆ ~UsuallySmallMap()

template<typename Key2 , typename Value , int array_max>
ogdf::UsuallySmallMap< Key2, Value, array_max >::~UsuallySmallMap ( )
inline

Definition at line 63 of file RegisteredMultiArray.h.

◆ UsuallySmallMap() [2/3]

template<typename Key2 , typename Value , int array_max>
ogdf::UsuallySmallMap< Key2, Value, array_max >::UsuallySmallMap ( const UsuallySmallMap< Key2, Value, array_max > &  copy)
inline

Definition at line 75 of file RegisteredMultiArray.h.

◆ UsuallySmallMap() [3/3]

template<typename Key2 , typename Value , int array_max>
ogdf::UsuallySmallMap< Key2, Value, array_max >::UsuallySmallMap ( UsuallySmallMap< Key2, Value, array_max > &&  move)
inlinenoexcept

Definition at line 87 of file RegisteredMultiArray.h.

Member Function Documentation

◆ contains()

template<typename Key2 , typename Value , int array_max>
bool ogdf::UsuallySmallMap< Key2, Value, array_max >::contains ( const Key2 &  key) const
inline

Definition at line 208 of file RegisteredMultiArray.h.

◆ empty()

template<typename Key2 , typename Value , int array_max>
bool ogdf::UsuallySmallMap< Key2, Value, array_max >::empty ( ) const
inline

Definition at line 226 of file RegisteredMultiArray.h.

◆ get_or_create()

template<typename Key2 , typename Value , int array_max>
Value& ogdf::UsuallySmallMap< Key2, Value, array_max >::get_or_create ( const Key2 &  key,
const Value &  def = Value() 
)
inline

Definition at line 122 of file RegisteredMultiArray.h.

◆ get_or_raise()

template<typename Key2 , typename Value , int array_max>
Value& ogdf::UsuallySmallMap< Key2, Value, array_max >::get_or_raise ( const Key2 &  key) const
inline

Definition at line 180 of file RegisteredMultiArray.h.

◆ getValueArray()

template<typename Key2 , typename Value , int array_max>
ValueArrayType& ogdf::UsuallySmallMap< Key2, Value, array_max >::getValueArray ( ) const
inline

Definition at line 246 of file RegisteredMultiArray.h.

◆ getValueMap()

template<typename Key2 , typename Value , int array_max>
ValueMapType& ogdf::UsuallySmallMap< Key2, Value, array_max >::getValueMap ( ) const
inline

Definition at line 252 of file RegisteredMultiArray.h.

◆ getValueScalar()

template<typename Key2 , typename Value , int array_max>
ValuePairType& ogdf::UsuallySmallMap< Key2, Value, array_max >::getValueScalar ( ) const
inline

Definition at line 240 of file RegisteredMultiArray.h.

◆ operator=()

template<typename Key2 , typename Value , int array_max>
UsuallySmallMap& ogdf::UsuallySmallMap< Key2, Value, array_max >::operator= ( UsuallySmallMap< Key2, Value, array_max >  copy_by_value)
inlinenoexcept

Assign this UsuallySmallMap to be a copy of copy_by_value.

Internally, this will use the copy constructor to create a temporary copy of the argument copy_by_value (as it is passed by value) and then swap this object instance with the temporary copy. If the assigned-from object can be moved, the move constructor will be automatically used instead of copying. Note that this method thereby covers both copy-assignment and move-assignment. See https://stackoverflow.com/a/3279550 for more details on this idiom. This method is noexcept as a potentially-throwing copy constructor call is made within the context of the caller (see https://stackoverflow.com/a/7628345) and swap is expected to be noexcept.

Definition at line 87 of file RegisteredMultiArray.h.

◆ size()

template<typename Key2 , typename Value , int array_max>
size_t ogdf::UsuallySmallMap< Key2, Value, array_max >::size ( ) const
inline

Definition at line 228 of file RegisteredMultiArray.h.

◆ unset()

template<typename Key2 , typename Value , int array_max>
void ogdf::UsuallySmallMap< Key2, Value, array_max >::unset ( const Key2 &  key)
inline

Definition at line 95 of file RegisteredMultiArray.h.

◆ usesMap()

template<typename Key2 , typename Value , int array_max>
bool ogdf::UsuallySmallMap< Key2, Value, array_max >::usesMap ( ) const
inline

Definition at line 238 of file RegisteredMultiArray.h.

Friends And Related Function Documentation

◆ swap

template<typename Key2 , typename Value , int array_max>
void swap ( UsuallySmallMap< Key2, Value, array_max > &  first,
UsuallySmallMap< Key2, Value, array_max > &  second 
)
friend

Definition at line 89 of file RegisteredMultiArray.h.

Member Data Documentation

◆ m_size

template<typename Key2 , typename Value , int array_max>
uint8_t ogdf::UsuallySmallMap< Key2, Value, array_max >::m_size = 0

Definition at line 57 of file RegisteredMultiArray.h.

◆ m_value

template<typename Key2 , typename Value , int array_max>
void* ogdf::UsuallySmallMap< Key2, Value, array_max >::m_value = nullptr

Definition at line 58 of file RegisteredMultiArray.h.


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