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

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

#include <linkedmap.h>

Public Types

using Ptr = std::unique_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)
 A non-const wrapper for find() const.
 
T * find (const QCString &key)
 A non-const wrapper for find() const.
 
T * find (const std::string &key)
 A non-const wrapper for find() const.
 
template<class... Args>
T * add (const char *k, Args &&... args)
 Adds a new object to the ordered vector if it was not added already. More...
 
template<class... Args>
T * add (const QCString &k, Args &&... args)
 
T * add (const char *k, Ptr &&ptr)
 Adds an existing object to the ordered vector (unless another object was already added under the same key). More...
 
T * add (const QCString &k, Ptr &&ptr)
 
template<class... Args>
T * prepend (const char *k, Args &&... args)
 Prepends a new object to the ordered vector if it was not added already. More...
 
template<class... Args>
T * prepend (const QCString &key, Args &&... args)
 
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 LinkedMap< T, Hash, KeyEqual, Map >

Container class representing a vector of objects with keys.

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

Member Function Documentation

◆ add() [1/2]

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 >>
template<class... Args>
T* LinkedMap< T, Hash, KeyEqual, Map >::add ( const char *  k,
Args &&...  args 
)
inline

Adds a new object to the ordered vector if it was not added already.

Return a non-owning pointer to the newly added object, or to the existing object if it was already inserted before under the given key.

◆ add() [2/2]

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 >>
T* LinkedMap< T, Hash, KeyEqual, Map >::add ( const char *  k,
Ptr &&  ptr 
)
inline

Adds an existing object to the ordered vector (unless another object was already added under the same key).

Ownership is transferred. Return a non-owning pointer to the newly added object, or to the existing object if it was already inserted before under the given key.

◆ 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 LinkedMap< 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* LinkedMap< T, Hash, KeyEqual, Map >::find ( const std::string &  key) const
inline

Find an object given the key.

Returns a pointer to the element 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* LinkedMap< T, Hash, KeyEqual, Map >::find ( const QCString key) const
inline

Find an object given the key.

Returns a pointer to the element 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* LinkedMap< T, Hash, KeyEqual, Map >::find ( const char *  key) const
inline

Find an object given the key.

Returns a pointer to the element 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 >>
template<class... Args>
T* LinkedMap< T, Hash, KeyEqual, Map >::prepend ( const char *  k,
Args &&...  args 
)
inline

Prepends a new object to the ordered vector if it was not added already.

Return a non-owning pointer to the newly added object, or to the existing object if it was already inserted before under the given key.


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