Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
BidirectionalMap< T, U > Class Template Reference

Maintains a one-to-one mapping that can be queried from either side. More...

#include <BidirectionalMap.h>

Collaboration diagram for BidirectionalMap< T, U >:

Classes

class  Side
 Read-only view for one direction of the map. More...

Public Types

using LeftSideType = Side<T, U>
 Read-only view that maps T to U.
using RightSideType = Side<U, T>
 Read-only view that maps U to T.

Public Member Functions

 BidirectionalMap ()=default
 Creates an empty bidirectional map.
LeftSideType & get_left ()
 Gets the left-to-right view.
const LeftSideType & get_left () const
 Gets the left-to-right view.
RightSideType & get_right ()
 Gets the right-to-left view.
const RightSideType & get_right () const
 Gets the right-to-left view.
void insert (const T &key, const U &value)
 Inserts or replaces a one-to-one mapping.
template<typename KT, typename KU>
void emplace (KT &&key, KU &&value)
 Constructs or replaces a one-to-one mapping in place.
void remove_left (const T &key)
 Removes a mapping by left-side key.
void remove_right (const U &key)
 Removes a mapping by right-side key.
void clear ()
 Removes all mappings from both sides.
void reserve (size_t n)
 Reserves storage for mappings on both sides.

Private Attributes

LeftSideType left {}
RightSideType right {}

Detailed Description

template<typename T, typename U>
class BidirectionalMap< T, U >

Maintains a one-to-one mapping that can be queried from either side.

Inserting a key or value that already exists removes the previous opposite mapping before storing the new pair.

Template Parameters
TLeft-side key type.
URight-side key type.

Definition at line 16 of file BidirectionalMap.h.

Member Typedef Documentation

◆ LeftSideType

template<typename T, typename U>
using BidirectionalMap< T, U >::LeftSideType = Side<T, U>

Read-only view that maps T to U.

Definition at line 98 of file BidirectionalMap.h.

◆ RightSideType

template<typename T, typename U>
using BidirectionalMap< T, U >::RightSideType = Side<U, T>

Read-only view that maps U to T.

Definition at line 99 of file BidirectionalMap.h.

Constructor & Destructor Documentation

◆ BidirectionalMap()

template<typename T, typename U>
BidirectionalMap< T, U >::BidirectionalMap ( )
default

Creates an empty bidirectional map.

Member Function Documentation

◆ clear()

template<typename T, typename U>
void BidirectionalMap< T, U >::clear ( )
inline

Removes all mappings from both sides.

Definition at line 208 of file BidirectionalMap.h.

References left, and right.

◆ emplace()

template<typename T, typename U>
template<typename KT, typename KU>
void BidirectionalMap< T, U >::emplace ( KT && key,
KU && value )
inline

Constructs or replaces a one-to-one mapping in place.

Template Parameters
KTForwarded left-side key type.
KUForwarded right-side value type.
Parameters
keyLeft-side key.
valueRight-side value.

Definition at line 162 of file BidirectionalMap.h.

References left, and right.

◆ get_left() [1/2]

template<typename T, typename U>
LeftSideType & BidirectionalMap< T, U >::get_left ( )
inline

Gets the left-to-right view.

Returns
Mutable left-side view.

Definition at line 110 of file BidirectionalMap.h.

References left.

◆ get_left() [2/2]

template<typename T, typename U>
const LeftSideType & BidirectionalMap< T, U >::get_left ( ) const
inline

Gets the left-to-right view.

Returns
Const left-side view.

Definition at line 116 of file BidirectionalMap.h.

References left.

◆ get_right() [1/2]

template<typename T, typename U>
RightSideType & BidirectionalMap< T, U >::get_right ( )
inline

Gets the right-to-left view.

Returns
Mutable right-side view.

Definition at line 122 of file BidirectionalMap.h.

References right.

◆ get_right() [2/2]

template<typename T, typename U>
const RightSideType & BidirectionalMap< T, U >::get_right ( ) const
inline

Gets the right-to-left view.

Returns
Const right-side view.

Definition at line 128 of file BidirectionalMap.h.

References right.

◆ insert()

template<typename T, typename U>
void BidirectionalMap< T, U >::insert ( const T & key,
const U & value )
inline

Inserts or replaces a one-to-one mapping.

Parameters
keyLeft-side key.
valueRight-side value.

Definition at line 135 of file BidirectionalMap.h.

References left, and right.

◆ remove_left()

template<typename T, typename U>
void BidirectionalMap< T, U >::remove_left ( const T & key)
inline

Removes a mapping by left-side key.

Parameters
keyLeft-side key to remove.

Definition at line 183 of file BidirectionalMap.h.

References left, and right.

◆ remove_right()

template<typename T, typename U>
void BidirectionalMap< T, U >::remove_right ( const U & key)
inline

Removes a mapping by right-side key.

Parameters
keyRight-side key to remove.

Definition at line 196 of file BidirectionalMap.h.

References left, and right.

◆ reserve()

template<typename T, typename U>
void BidirectionalMap< T, U >::reserve ( size_t n)
inline

Reserves storage for mappings on both sides.

Parameters
nNumber of mappings to reserve.

Definition at line 217 of file BidirectionalMap.h.

References left, and right.

Member Data Documentation

◆ left

template<typename T, typename U>
LeftSideType BidirectionalMap< T, U >::left {}
private

◆ right


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