commonlib
VectorWithKeys< KeyType, ValueType > Class Template Reference

Public Types

using iterator = VectorWithKeysIterators::VectorWithKeysIterator< KeyType, ValueType, VectorWithKeysIterators::ConstTypeSwitch::isNonConst >
 
using const_iterator = VectorWithKeysIterators::VectorWithKeysIterator< KeyType, ValueType, VectorWithKeysIterators::ConstTypeSwitch::isConst >
 

Public Member Functions

 VectorWithKeys ()
 Default constructor.
 
 VectorWithKeys (const VectorWithKeys< KeyType, ValueType > &other)
 Copy constructor.
 
VectorWithKeys< KeyType, ValueType > & operator= (const VectorWithKeys< KeyType, ValueType > &other)
 Copy assignment.
 
 VectorWithKeys (VectorWithKeys< KeyType, ValueType > &&other)
 Move constructor.
 
VectorWithKeys< KeyType, ValueType > & operator= (VectorWithKeys< KeyType, ValueType > &&other)
 Move assignment.
 
const KeyType & getKey (std::size_t pos) const
 
ValueType & operator[] (std::size_t pos)
 Mutable access element at position. More...
 
const ValueType & operator[] (std::size_t pos) const
 Read only access to element at position. More...
 
ValueType & back ()
 Mutable access to the last element in the container. More...
 
const ValueType & back () const
 Read only access to the last element in the container. More...
 
void clear ()
 Deletes all objects in the container and sets the size to zero.
 
std::size_t size () const
 
bool empty () const
 
bool emplaceBackWithKey (const KeyType &key)
 Constructs an additional element at the at the back of the container by calling a default constructor if the key value passed isn't yet taken. More...
 
iterator erase (iterator position)
 Erases an element at an iterator position. More...
 
iterator erase (std::size_t pos)
 Erases an element at an iterator position. More...
 
void swap (int32_t posA, int32_t posB)
 Swaps elements in container at indexed positions passed. More...
 
iterator findByKey (const KeyType &key)
 Searches for an element with a key value passed. More...
 
const_iterator findByKey (const KeyType &key) const
 Searches for an element with a key value passed. More...
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
const_iterator cbegin () const
 
const_iterator cend () const
 

Member Function Documentation

◆ back() [1/2]

template<typename KeyType , typename ValueType >
ValueType & VectorWithKeys< KeyType, ValueType >::back ( )

Mutable access to the last element in the container.

Returns
reference to the last element in container

◆ back() [2/2]

template<typename KeyType , typename ValueType >
const ValueType & VectorWithKeys< KeyType, ValueType >::back ( ) const

Read only access to the last element in the container.

Returns
constant reference to the last element in container

◆ begin() [1/2]

template<typename KeyType, typename ValueType>
iterator VectorWithKeys< KeyType, ValueType >::begin ( )
inline
Returns
an iterator pointing to the first element of the container

◆ begin() [2/2]

template<typename KeyType, typename ValueType>
const_iterator VectorWithKeys< KeyType, ValueType >::begin ( ) const
inline
Returns
a constant iterator pointing to the first element of the container

◆ cbegin()

template<typename KeyType, typename ValueType>
const_iterator VectorWithKeys< KeyType, ValueType >::cbegin ( ) const
inline
Returns
a constant iterator pointing to the first element of the container

◆ cend()

template<typename KeyType, typename ValueType>
const_iterator VectorWithKeys< KeyType, ValueType >::cend ( ) const
inline
Returns
a constant iterator pointing to position past the last element of the container

◆ emplaceBackWithKey()

template<typename KeyType , typename ValueType >
bool VectorWithKeys< KeyType, ValueType >::emplaceBackWithKey ( const KeyType &  key)

Constructs an additional element at the at the back of the container by calling a default constructor if the key value passed isn't yet taken.

True is returned only when an element has been added.

Parameters
keyvalue of the newly constructed element at the back of container
Returns
true if element with passed key value was added to the container

◆ empty()

template<typename KeyType , typename ValueType >
bool VectorWithKeys< KeyType, ValueType >::empty ( ) const
Returns
true if the container is empty otherwise false

◆ end() [1/2]

template<typename KeyType, typename ValueType>
iterator VectorWithKeys< KeyType, ValueType >::end ( )
inline
Returns
an iterator pointing to position past the last element of the container

◆ end() [2/2]

template<typename KeyType, typename ValueType>
const_iterator VectorWithKeys< KeyType, ValueType >::end ( ) const
inline
Returns
a constant iterator pointing to position past the last element of the container

◆ erase() [1/2]

template<typename KeyType , typename ValueType >
VectorWithKeys< KeyType, ValueType >::iterator VectorWithKeys< KeyType, ValueType >::erase ( iterator  position)

Erases an element at an iterator position.

Parameters
positionand iterator pointing to the single element to be removed from the container
Returns
an iterator pointing to the new location of the element that followed the element erased by the function call

◆ erase() [2/2]

template<typename KeyType , typename ValueType >
VectorWithKeys< KeyType, ValueType >::iterator VectorWithKeys< KeyType, ValueType >::erase ( std::size_t  pos)

Erases an element at an iterator position.

Parameters
indexof a single element to be removed from the container
Returns
an iterator pointing to the new location of the element that followed the element erased by the function call

◆ findByKey() [1/2]

template<typename KeyType , typename ValueType >
VectorWithKeys< KeyType, ValueType >::iterator VectorWithKeys< KeyType, ValueType >::findByKey ( const KeyType &  key)

Searches for an element with a key value passed.

Returns an iterator pointing to the element with a passed key value. If element with that key doesn't exist an iterator pointing container end is returned.

Parameters
keyvalue of an element being searched
Returns
an iterator pointing to the element found or to container end if element wasn't found

◆ findByKey() [2/2]

template<typename KeyType , typename ValueType >
VectorWithKeys< KeyType, ValueType >::const_iterator VectorWithKeys< KeyType, ValueType >::findByKey ( const KeyType &  key) const

Searches for an element with a key value passed.

Returns a constant iterator pointing to the element with a passed key value. If element with that key doesn't exist an iterator pointing container end is returned.

Parameters
keyvalue of an element being searched
Returns
a constant iterator pointing to the element found or to container end if element wasn't found

◆ getKey()

template<typename KeyType , typename ValueType >
const KeyType & VectorWithKeys< KeyType, ValueType >::getKey ( std::size_t  pos) const
Parameters
posindex position in container
Returns
key value at index position

◆ operator[]() [1/2]

template<typename KeyType , typename ValueType >
ValueType & VectorWithKeys< KeyType, ValueType >::operator[] ( std::size_t  pos)

Mutable access element at position.

Parameters
posindex position of an element
Returns
reference of an object at the position

◆ operator[]() [2/2]

template<typename KeyType , typename ValueType >
const ValueType & VectorWithKeys< KeyType, ValueType >::operator[] ( std::size_t  pos) const

Read only access to element at position.

Parameters
posindex position of an element
Returns
constant reference of an object at the position

◆ size()

template<typename KeyType , typename ValueType >
std::size_t VectorWithKeys< KeyType, ValueType >::size ( ) const
Returns
number of elements in the container

◆ swap()

template<typename KeyType , typename ValueType >
void VectorWithKeys< KeyType, ValueType >::swap ( int32_t  posA,
int32_t  posB 
)

Swaps elements in container at indexed positions passed.

Parameters
posAindex of the to be swapped element
posBindex of the to be swapped element

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