Base Framework
Public Types | Public Member Functions | List of all members
ArrayMap< KEY, VALUE > Class Template Reference

Association of value with value. More...

#include <base/collection/ArrayMap.h>

Inherits Array< Association< KEY, VALUE > >.

Public Types

typedef Association< KEY, VALUE > Node
 
typedef Array< Association< KEY, VALUE > > Base
 
- Public Types inherited from Array< Association< KEY, VALUE > >
typedef Association< KEY, VALUE > Value
 
typedef Allocator< Association< KEY, VALUE > >::Iterator Iterator
 
typedef Allocator< Association< KEY, VALUE > >::ReadIterator ReadIterator
 
typedef Allocator< Association< KEY, VALUE > >::Enumerator Enumerator
 
typedef Allocator< Association< KEY, VALUE > >::ReadEnumerator ReadEnumerator
 

Public Member Functions

 ArrayMap () noexcept
 
 ArrayMap (std::initializer_list< Node > values)
 
 ArrayMap (const ArrayMap &copy)
 
 ArrayMap (ArrayMap &&move) noexcept
 
ArrayMapoperator= (const ArrayMap &assign)
 
ArrayMapoperator= (ArrayMap &&assign)
 
Nodefind (const KEY &key)
 
const Nodefind (const KEY &key) const
 
bool hasKey (const KEY &key) const noexcept
 
VALUE & getValue (const KEY &key)
 
const VALUE & getValue (const KEY &key) const
 
bool add (const KEY &key, const VALUE &value)
 
- Public Member Functions inherited from Array< Association< KEY, VALUE > >
void setSize (MemorySize size)
 
void setSize (MemorySize size, const Association< KEY, VALUE > &value)
 
void ensureCapacity (MemorySize capacity)
 
MemorySize getCapacity () const noexcept
 
ValuegetElements ()
 
const ValuegetElements () const noexcept
 
 Array ()
 
 Array (MemorySize size)
 
 Array (MemorySize size, const Value &value)
 
 Array (std::initializer_list< Value > l)
 
 Array (const Array &copy) noexcept
 
 Array (Array &&move) noexcept
 
Arrayoperator= (const Array &copy) noexcept
 
Arrayoperator= (Array &&move) noexcept
 
MemorySize getSize () const noexcept
 
bool isEmpty () const noexcept
 
Association< KEY, VALUE > * getFirstReference () noexcept
 
const Association< KEY, VALUE > * getFirstReference () const noexcept
 
Association< KEY, VALUE > & getFirst ()
 
const Association< KEY, VALUE > & getFirst () const
 
Association< KEY, VALUE > & getLast ()
 
const Association< KEY, VALUE > & getLast () const
 
Iterator getBeginIterator () noexcept
 
Iterator getEndIterator () noexcept
 
ReadIterator getBeginReadIterator () const noexcept
 
ReadIterator getEndReadIterator () const noexcept
 
ReadIterator begin () const noexcept
 
Iterator begin () noexcept
 
ReadIterator end () const noexcept
 
Iterator end () noexcept
 
ReadIterator cbegin () const noexcept
 
ReadIterator cend () const noexcept
 
 operator RandomAccessIterable< Iterator > () noexcept
 
Enumerator getEnumerator () noexcept
 
ReadEnumerator getReadEnumerator () const noexcept
 
void append (const Value &value)
 
void append (Value &&value)
 
void append (std::initializer_list< Value > l)
 
void prepend (const Value &value)
 
void prepend (Value &&value)
 
void prepend (std::initializer_list< Value > l)
 
void insert (MemorySize index, const Value &value)
 
void insert (MemorySize index, Value &&value)
 
void insert (const Iterator &it, const Value &value)
 
void insert (const Iterator &it, Value &&value)
 
void remove (MemorySize index)
 
void remove (const Iterator &it)
 
void remove (MemorySize _begin, MemorySize _end)
 
void remove (const Iterator &_begin, const Iterator &_end)
 
void removeAll ()
 
Array slice (MemorySize _begin, MemorySize _end) const
 
Array slice (const Iterator &_begin, const Iterator &_end) const
 
ValuegetAt (MemorySize index)
 
const ValuegetAt (MemorySize index) const
 
void setAt (MemorySize index, const Value &value)
 
void setAt (MemorySize index, Value &&value)
 
Association< KEY, VALUE > & operator[] (MemorySize index)
 
const Valueoperator[] (MemorySize index) const
 
bool operator== (const Array &compare) const
 
bool operator!= (const Array &compare) const
 
bool operator< (const Array &compare) const
 
bool operator>= (const Array &compare) const
 
 operator bool () const noexcept
 
void shuffle ()
 
MemoryDiff indexOf (const Association< KEY, VALUE > &value) const
 
MemoryDiff lastIndexOf (const Association< KEY, VALUE > &value) const
 
const Association< KEY, VALUE > * find (const Association< KEY, VALUE > &value) const
 
void sort ()
 
void sort (PREDICATE predicate)
 
Array head (MemorySize n) const
 
Array tail (MemorySize n) const
 
Arrayoperator<< (const Association< KEY, VALUE > &value)
 
Arrayoperator<< (Association< KEY, VALUE > &&value)
 

Additional Inherited Members

Detailed Description

template<class KEY, class VALUE>
class ArrayMap< KEY, VALUE >

Association of value with value.

Map using Array container. Use this for returning a limited size set of values from functions.

Linear search for key! But fine as long as only a few items are added.

See also
Map

Constructor & Destructor Documentation

◆ ArrayMap() [1/4]

template<class KEY , class VALUE >
ArrayMap< KEY, VALUE >::ArrayMap ( )
inlinenoexcept

Initializes an empty map.

◆ ArrayMap() [2/4]

template<class KEY , class VALUE >
ArrayMap< KEY, VALUE >::ArrayMap ( std::initializer_list< Node values)
inline

Initializes map with given values.

◆ ArrayMap() [3/4]

template<class KEY , class VALUE >
ArrayMap< KEY, VALUE >::ArrayMap ( const ArrayMap< KEY, VALUE > &  copy)
inline

Initializes map from other map.

◆ ArrayMap() [4/4]

template<class KEY , class VALUE >
ArrayMap< KEY, VALUE >::ArrayMap ( ArrayMap< KEY, VALUE > &&  move)
inlinenoexcept

Initializes map from other map.

Member Function Documentation

◆ add()

template<class KEY , class VALUE >
bool ArrayMap< KEY, VALUE >::add ( const KEY &  key,
const VALUE &  value 
)
inline

Associates the specified key with the specified value in this map. If the key already is associated with a value, the value is overridden. Linear search for key.

Parameters
keyThe key.
valueThe value.
Returns
Returns true if new key was added.

◆ find() [1/2]

template<class KEY , class VALUE >
Node* ArrayMap< KEY, VALUE >::find ( const KEY &  key)
inline

Returns reference to the item if found by the given value.

◆ find() [2/2]

template<class KEY , class VALUE >
const Node* ArrayMap< KEY, VALUE >::find ( const KEY &  key) const
inline

Returns reference to the item if found by the given value.

◆ getValue() [1/2]

template<class KEY , class VALUE >
VALUE& ArrayMap< KEY, VALUE >::getValue ( const KEY &  key)
inline

Returns the value of associated with the given key. Throws InvalidKey is key does not exist.

◆ getValue() [2/2]

template<class KEY , class VALUE >
const VALUE& ArrayMap< KEY, VALUE >::getValue ( const KEY &  key) const
inline

Returns the value of associated with the given key. Throws InvalidKey is key does not exist.

◆ hasKey()

template<class KEY , class VALUE >
bool ArrayMap< KEY, VALUE >::hasKey ( const KEY &  key) const
inlinenoexcept

Returns true if the key exists.

◆ operator=() [1/2]

template<class KEY , class VALUE >
ArrayMap& ArrayMap< KEY, VALUE >::operator= ( ArrayMap< KEY, VALUE > &&  assign)
inline

Assign map.

◆ operator=() [2/2]

template<class KEY , class VALUE >
ArrayMap& ArrayMap< KEY, VALUE >::operator= ( const ArrayMap< KEY, VALUE > &  assign)
inline

Assign map.