doxygen
Public Types | Public Member Functions | List of all members
LinkedRefMap< T, Hash, KeyEqual, Map > Class Template Reference

Container class representing a vector of objects with keys. More...

#include <linkedmap.h>

Public Types

using Ptr = T *
 
using Vec = std::vector< Ptr >
 
using iterator = typename Vec::iterator
 
using const_iterator = typename Vec::const_iterator
 
using reverse_iterator = typename Vec::reverse_iterator
 
using const_reverse_iterator = typename Vec::const_reverse_iterator
 

Public Member Functions

const T * find (const std::string &key) const
 find an object given the key. More...
 
const T * find (const QCString &key) const
 find an object given the key. More...
 
const T * find (const char *key) const
 find an object given the key. More...
 
T * find (const char *key)
 non-const wrapper for find() const
 
T * find (const QCString &key)
 
T * find (const std::string &key)
 non-const wrapper for find() const
 
bool add (const char *k, T *obj)
 Adds an object reference to the ordered vector if it was not added already. More...
 
bool add (const QCString &k, T *obj)
 
bool prepend (const char *k, T *obj)
 Prepends an object reference to the ordered vector if it was not added already. More...
 
bool prepend (const QCString &key, T *obj)
 
bool del (const QCString &key)
 Removes an object from the container and deletes it. More...
 
Ptr & operator[] (size_t pos)
 
const Ptr & operator[] (size_t pos) const
 
iterator begin ()
 
iterator end ()
 
const_iterator begin () const
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
reverse_iterator rend ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
bool empty () const
 
size_t size () const
 
void clear ()
 

Detailed Description

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
class LinkedRefMap< T, Hash, KeyEqual, Map >

Container class representing a vector of objects with keys.

Objects can be efficiently be looked up given the key. Objects are not owned by the container, the container will only hold references. When adding objects the order of addition is kept, and used while iterating.

Member Function Documentation

◆ add()

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
bool LinkedRefMap< T, Hash, KeyEqual, Map >::add ( const char *  k,
T *  obj 
)
inline

Adds an object reference to the ordered vector if it was not added already.

Return true if the reference was added, and false if an object with the same key was already added before

◆ del()

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
bool LinkedRefMap< T, Hash, KeyEqual, Map >::del ( const QCString key)
inline

Removes an object from the container and deletes it.

Returns true if the object was deleted or false it is was not found.

◆ find() [1/3]

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
const T* LinkedRefMap< T, Hash, KeyEqual, Map >::find ( const std::string &  key) const
inline

find an object given the key.

Returns a pointer to the object if found or nullptr if it is not found.

◆ find() [2/3]

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
const T* LinkedRefMap< T, Hash, KeyEqual, Map >::find ( const QCString key) const
inline

find an object given the key.

Returns a pointer to the object if found or nullptr if it is not found.

◆ find() [3/3]

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
const T* LinkedRefMap< T, Hash, KeyEqual, Map >::find ( const char *  key) const
inline

find an object given the key.

Returns a pointer to the object if found or nullptr if it is not found.

◆ prepend()

template<class T, class Hash = std::hash<std::string>, class KeyEqual = std::equal_to<std::string>, class Map = std::unordered_map<std::string,T*,Hash,KeyEqual >>
bool LinkedRefMap< T, Hash, KeyEqual, Map >::prepend ( const char *  k,
T *  obj 
)
inline

Prepends an object reference to the ordered vector if it was not added already.

Return true if the reference was added, and false if an object with the same key was already added before


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