GEOS
Public Types | Public Member Functions | List of all members
geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE > Class Template Reference

#include <MappedVector.hpp>

Public Types

using key_type = KEY_TYPE
 The type used for the key of the map.
 
using mapped_type = T_PTR
 pointer to the value type
 
using LookupMapType = std::unordered_map< KEY_TYPE, INDEX_TYPE >
 the type of the lookup map
 
using value_type = typename std::pair< KEY_TYPE, T_PTR >
 the type of the values held in the vector
 
using const_key_value_type = typename std::pair< KEY_TYPE const, T * >
 the type of the values with const keys held in the vector
 
using const_value_type = typename std::pair< KEY_TYPE const, T const * >
 a const type of the values held in the vector
 
using valueContainer = std::vector< value_type >
 the type of the vector container
 
using constKeyValueContainer = std::vector< const_key_value_type >
 a const type of the vector container
 
using constValueContainer = std::vector< const_value_type >
 a const type of the vector container
 
using pointer = typename valueContainer::pointer
 the pointer type of the value container
 
using const_pointer = typename valueContainer::const_pointer
 the pointer to const type of the value container
 
using reference = typename valueContainer::reference
 reference type of the value container
 
using const_reference = typename valueContainer::const_reference
 reference to const type of the value container
 
using size_type = typename valueContainer::size_type
 the size_type of the value container
 
using iterator = typename constKeyValueContainer::iterator
 the iterator type of the value container
 
using const_iterator = typename constValueContainer::const_iterator
 the iterator to const type of the value container
 
using reverse_iterator = typename constKeyValueContainer::reverse_iterator
 the reverse iterator type of the value container
 
using const_reverse_iterator = typename constValueContainer::const_reverse_iterator
 the reverse iterator to const type of the value container
 
using KeyIndex = KeyIndexT< KEY_TYPE const, INDEX_TYPE >
 alias for the KeyIndex itself
 

Public Member Functions

 MappedVector ()=default
 deleted default constructor
 
 ~MappedVector ()
 default destructor
 
 MappedVector (MappedVector const &)=default
 Default copy constructor.
 
MappedVectoroperator= (MappedVector const &)=default
 Default copy assignment operator. More...
 
 MappedVector (MappedVector &&)=default
 Default move operator.
 
MappedVectoroperator= (MappedVector &&)=default
 Default move assignment operator. More...
 
INDEX_TYPE getIndex (KEY_TYPE const &key) const
 
INDEX_TYPE size () const
 function to return the number of entries stored More...
 
valueContainer const & values ()
 access for value container More...
 
constValueContainer const & values () const
 access for value container More...
 
LookupMapType const & keys () const
 access for key lookup More...
 
element access functions
T const * operator[] (INDEX_TYPE index) const
 
T * operator[] (INDEX_TYPE index)
 
T const * operator[] (KEY_TYPE const &keyName) const
 
T * operator[] (KEY_TYPE const &keyName)
 
T const * operator[] (KeyIndex const &keyIndex) const
 
T * operator[] (KeyIndex const &keyIndex)
 
iterator functions
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin ()
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend ()
 
modifier functions
T * insert (KEY_TYPE const &keyName, T_PTR source, bool takeOwnership, bool overwrite=false)
 insert new entry into MappedVector More...
 
void erase (INDEX_TYPE index)
 Remove element at given index. More...
 
void erase (KEY_TYPE const &key)
 Remove element at given key. More...
 
void erase (KeyIndex &keyIndex)
 Remove element at given key. More...
 
void clear ()
 function to clear the MappedVector
 

Detailed Description

template<typename T, typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
class geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >

This class defines a stl-like container that stores values in an stl vector, and has a map lookup table to access the values by a key. It combines the random access performance of a vector when the index is known, the flexibility of a mapped key lookup O(n) if only the key is known.

In addition, a keyIndex can be used for lookup, which will give similar performance to an index lookup after the first use of a keyIndex.

Definition at line 49 of file MappedVector.hpp.

Member Function Documentation

◆ begin() [1/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::begin ( )
inline
Returns
a read/write iterator that points to the first element in the in m_objects.

Definition at line 236 of file MappedVector.hpp.

◆ begin() [2/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
const_iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::begin ( ) const
inline
Returns
a read-only iterator that points to the first element in the in m_objects.

Definition at line 243 of file MappedVector.hpp.

◆ cbegin()

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
const_iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::cbegin ( )
inline
Returns
a read-only iterator that points to the first element in the in m_objects.

Definition at line 250 of file MappedVector.hpp.

◆ cend()

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
const_iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::cend ( )
inline
Returns
a read-only iterator that points to the last element in the in m_objects.

Definition at line 271 of file MappedVector.hpp.

◆ end() [1/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::end ( )
inline
Returns
a read/write iterator that points to the last element in the in m_objects.

Definition at line 257 of file MappedVector.hpp.

◆ end() [2/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
const_iterator geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::end ( ) const
inline
Returns
a read-only iterator that points to the last element in the in m_objects.

Definition at line 264 of file MappedVector.hpp.

◆ erase() [1/3]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
void geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::erase ( INDEX_TYPE  index)
inline

Remove element at given index.

Parameters
indexindex of element to remove.

Completely remove element at given index and corresponding key lookup. If pointed-to object is owned, it is deleted.

Definition at line 315 of file MappedVector.hpp.

◆ erase() [2/3]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
void geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::erase ( KEY_TYPE const &  key)
inline

Remove element at given key.

Parameters
keykey of element to remove.

This function will set the element at the given key to nullptr.

Definition at line 349 of file MappedVector.hpp.

◆ erase() [3/3]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
void geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::erase ( KeyIndex keyIndex)
inline

Remove element at given key.

Parameters
keyIndexkey of element to remove.

This function will set the element at the given key to nullptr.

Definition at line 364 of file MappedVector.hpp.

◆ getIndex()

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
INDEX_TYPE geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::getIndex ( KEY_TYPE const &  key) const
inline
Parameters
keyvalue of the key to use in the lookup
Returns
index associated with key

Definition at line 281 of file MappedVector.hpp.

◆ insert()

template<typename T , typename T_PTR , typename KEY_TYPE , typename INDEX_TYPE >
T * geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::insert ( KEY_TYPE const &  keyName,
T_PTR  source,
bool  takeOwnership,
bool  overwrite = false 
)

insert new entry into MappedVector

Parameters
keyNamekey name to assocaite with the new object
sourcepointer to object
takeOwnershipwhether or not to take ownership of the object
overwriteif the key already exists, overwrite indicates whether or not overwrite the existing entry
Returns
pointer to the object that is held in the MappedVector

Definition at line 465 of file MappedVector.hpp.

◆ keys()

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
LookupMapType const& geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::keys ( ) const
inline

access for key lookup

Returns
reference lookup map

Definition at line 422 of file MappedVector.hpp.

◆ operator=() [1/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
MappedVector& geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator= ( MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE > &&  )
default

Default move assignment operator.

Returns

◆ operator=() [2/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
MappedVector& geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator= ( MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE > const &  )
default

Default copy assignment operator.

Returns

◆ operator[]() [1/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( INDEX_TYPE  index)
inline
Parameters
index
Returns
pointer to T

Definition at line 169 of file MappedVector.hpp.

◆ operator[]() [2/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T const* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( INDEX_TYPE  index) const
inline
Parameters
index
Returns
pointer to const T

Definition at line 158 of file MappedVector.hpp.

◆ operator[]() [3/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( KEY_TYPE const &  keyName)
inline
Parameters
keyName
Returns
pointer to T

Definition at line 188 of file MappedVector.hpp.

◆ operator[]() [4/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T const* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( KEY_TYPE const &  keyName) const
inline
Parameters
keyName
Returns
pointer to const T

Definition at line 177 of file MappedVector.hpp.

◆ operator[]() [5/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( KeyIndex const &  keyIndex)
inline
Parameters
keyIndex
Returns
pointer to T

Definition at line 221 of file MappedVector.hpp.

◆ operator[]() [6/6]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
T const* geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::operator[] ( KeyIndex const &  keyIndex) const
inline
Parameters
keyIndex
Returns
pointer to const T

Definition at line 196 of file MappedVector.hpp.

◆ size()

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
INDEX_TYPE geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::size ( ) const
inline

function to return the number of entries stored

Returns
number of entries in MappedVector

Definition at line 399 of file MappedVector.hpp.

◆ values() [1/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
valueContainer const& geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::values ( )
inline

access for value container

Returns
reference to valueContainer

Definition at line 408 of file MappedVector.hpp.

◆ values() [2/2]

template<typename T , typename T_PTR = T *, typename KEY_TYPE = string, typename INDEX_TYPE = int>
constValueContainer const& geos::MappedVector< T, T_PTR, KEY_TYPE, INDEX_TYPE >::values ( ) const
inline

access for value container

Returns
reference to const valueContainer

Definition at line 415 of file MappedVector.hpp.


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