Template Class Map

Class Documentation

template<typename TKey, typename TValue>
class Map

Simple DLL-safe map of key object pairs.

Simple map type used to pass maps of key object pairs across the DLL boundary.

Template Parameters
  • TKey – : Type to use as the key

  • TValue – : Type to use as the value

Public Functions

inline Map()

Constructs a map with 0 elements.

inline Map(const Map<TKey, TValue> &Other)

Copy constructor.

Parameters

Other – const Map<TKey, TValue>&

inline Map(Map<TKey, TValue> &&Other)

Move constructor.

Parameters

Other – Map<TKey, TValue>&&

inline Map(const std::initializer_list<std::pair<const TKey, const TValue>> Values)

Constructs a map from a std::initializer_list.

Parameters

Values – const std::initializer_list<std::pair<const TKey, const TValue>> : Elements to construct the map from

inline ~Map()

Destructor.

Frees map memory.

inline TValue &operator[](const TKey &Key)

Returns a reference to the element with the given key in this map.

Will create a new element if the given key is not present.

Parameters

Key – const TKey& : Key of element in this map

Returns

TValue& : Map element

inline const TValue &operator[](const TKey &Key) const

Returns a const reference to the element with the given key in this map.

Throws if the given key is not present.

Parameters

Key – const TKey& : Key of element in this map

Returns

const TValue& : Map element

inline Map<TKey, TValue> &operator=(const Map<TKey, TValue> &Other)

Copy assignment.

Parameters

Other – const Map<TKey, TValue>&

Returns

Map<TKey, TValue>&

inline Map<TKey, TValue> &operator=(Map<TKey, TValue> &&Other)

Move assignment.

Parameters

Other – Map<TKey, TValue>&&

Returns

Map<TKey, TValue>&

inline bool operator==(const Map<TKey, TValue> &OtherValue) const
inline bool operator!=(const Map<TKey, TValue> &OtherValue) const
inline size_t Size() const

Returns the number of elements in this map.

Returns

size_t

inline bool HasKey(const TKey &Key) const

Returns true if this map contains an element with the given key.

Parameters

Key – const TKey& : key to check if the map contains

Returns

bool

inline const Array<TKey> *Keys() const

Returns a copy of all keys in this map.

This copy should be disposed by the caller once it is no longer needed.

Returns

const csp::common::Array<TKey>* : Array of keys

inline const Array<TValue> *Values() const

Returns all values in this map.

Returns

const csp::common::Array<TValue>* : Array of values

inline void Remove(const TKey &Key)

Removes the element with the given key from this map.

Parameters

Key – const TKey& : Key to remove from the map

inline void Clear()

Removes all elements in this map.