Doxygen
LinkedRefMap< T, Hash, KeyEqual, Map > 模板类 参考

Container class representing a vector of objects with keys. 更多...

#include <linkedmap.h>

+ 类 LinkedRefMap< T, Hash, KeyEqual, Map > 继承关系图:

Public 类型

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 成员函数

const T * find (const std::string &key) const
 find an object given the key. 更多...
 
const T * find (const QCString &key) const
 find an object given the key. 更多...
 
const T * find (const char *key) const
 find an object given the key. 更多...
 
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. 更多...
 
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. 更多...
 
bool prepend (const QCString &key, T *obj)
 
bool del (const QCString &key)
 Removes an object from the container and deletes it. 更多...
 
Ptroperator[] (size_t pos)
 
const Ptroperator[] (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 ()
 

Private 属性

Map m_lookup
 
Vec m_entries
 

详细描述

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.

在文件 linkedmap.h231 行定义.

成员类型定义说明

◆ const_iterator

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::const_iterator = typename Vec::const_iterator

在文件 linkedmap.h237 行定义.

◆ const_reverse_iterator

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::const_reverse_iterator = typename Vec::const_reverse_iterator

在文件 linkedmap.h239 行定义.

◆ iterator

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::iterator = typename Vec::iterator

在文件 linkedmap.h236 行定义.

◆ Ptr

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::Ptr = T*

在文件 linkedmap.h234 行定义.

◆ reverse_iterator

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::reverse_iterator = typename Vec::reverse_iterator

在文件 linkedmap.h238 行定义.

◆ Vec

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 >>
using LinkedRefMap< T, Hash, KeyEqual, Map >::Vec = std::vector<Ptr>

在文件 linkedmap.h235 行定义.

成员函数说明

◆ 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 >>
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

在文件 linkedmap.h284 行定义.

285  {
286  if (find(k)==nullptr) // new element
287  {
288  std::string key(k ? k : "");
289  m_lookup.insert({key,obj});
290  m_entries.push_back(obj);
291  return true;
292  }
293  else // already existing, don't add
294  {
295  return false;
296  }
297  }

被这些函数引用 GroupDefImpl::addClass(), GroupDefImpl::addConcept(), GroupDefImpl::addExample(), PageDefImpl::addInnerCompound(), NamespaceDefImpl::addInnerCompound(), ClassDefImpl::addInnerCompound(), GroupDefImpl::addNamespace(), GroupDefImpl::addPage(), NamespaceDefImpl::addUsingDeclaration(), FileDefImpl::addUsingDeclaration(), NamespaceDefImpl::addUsingDirective(), FileDefImpl::addUsingDirective(), NamespaceDefImpl::insertClass(), FileDefImpl::insertClass(), NamespaceDefImpl::insertConcept(), FileDefImpl::insertConcept(), NamespaceDefImpl::insertMember(), NamespaceDefImpl::insertNamespace() , 以及 FileDefImpl::insertNamespace().

◆ 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 >>
bool LinkedRefMap< T, Hash, KeyEqual, Map >::add ( const QCString k,
T *  obj 
)
inline

在文件 linkedmap.h299 行定义.

300  {
301  std::string key = k.str();
302  if (find(key)==nullptr) // new element
303  {
304  m_lookup.insert({key,obj});
305  m_entries.push_back(obj);
306  return true;
307  }
308  else // already existing, don't add
309  {
310  return false;
311  }
312  }

◆ begin() [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 >>
iterator LinkedRefMap< T, Hash, KeyEqual, Map >::begin ( )
inline

◆ begin() [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 >>
const_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::begin ( ) const
inline

在文件 linkedmap.h368 行定义.

368 { return m_entries.cbegin(); }

◆ clear()

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 >>
void LinkedRefMap< T, Hash, KeyEqual, Map >::clear ( )
inline

在文件 linkedmap.h377 行定义.

378  {
379  m_entries.clear();
380  m_lookup.clear();
381  }

◆ 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.

在文件 linkedmap.h348 行定义.

349  {
350  auto it = m_lookup.find(key.str());
351  if (it!=m_lookup.end())
352  {
353  auto vecit = std::find_if(m_entries.begin(),m_entries.end(),[obj=it->second](auto &el) { return el.get()==obj; });
354  if (vecit!=m_entries.end()) // should always be true
355  {
356  m_entries.erase(vecit);
357  m_lookup.erase(it);
358  return true;
359  }
360  }
361  return false;
362  }

◆ empty()

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 >::empty ( ) const
inline

◆ end() [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 >>
iterator LinkedRefMap< T, Hash, KeyEqual, Map >::end ( )
inline

◆ end() [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 >>
const_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::end ( ) const
inline

在文件 linkedmap.h369 行定义.

369 { return m_entries.cend(); }

◆ find() [1/6]

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* LinkedRefMap< T, Hash, KeyEqual, Map >::find ( const char *  key)
inline

non-const wrapper for find() const

在文件 linkedmap.h265 行定义.

266  {
267  return const_cast<T*>(static_cast<const LinkedRefMap&>(*this).find(key));
268  }

◆ find() [2/6]

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.

在文件 linkedmap.h259 行定义.

260  {
261  return find(std::string(key ? key : ""));
262  }

◆ find() [3/6]

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* LinkedRefMap< T, Hash, KeyEqual, Map >::find ( const QCString key)
inline

在文件 linkedmap.h270 行定义.

271  {
272  return const_cast<T*>(static_cast<const LinkedRefMap&>(*this).find(key));
273  }

◆ find() [4/6]

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.

在文件 linkedmap.h251 行定义.

252  {
253  auto it = m_lookup.find(key.str());
254  return it!=m_lookup.end() ? it->second : nullptr;
255  }

◆ find() [5/6]

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

non-const wrapper for find() const

在文件 linkedmap.h276 行定义.

277  {
278  return const_cast<T*>(static_cast<const LinkedRefMap&>(*this).find(key));
279  }

◆ find() [6/6]

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.

在文件 linkedmap.h243 行定义.

244  {
245  auto it = m_lookup.find(key);
246  return it!=m_lookup.end() ? it->second : nullptr;
247  }

被这些函数引用 LinkedRefMap< const ConceptDef >::add(), GroupDefImpl::addClass(), GroupDefImpl::addConcept(), ClassDefImpl::addMembersToTemplateInstance(), GroupDefImpl::addNamespace(), LinkedRefMap< const ConceptDef >::find(), findGlobalMember(), NamespaceDefImpl::findInnerCompound(), ClassDefImpl::findInnerCompound(), NamespaceDefImpl::getMemberByName() , 以及 LinkedRefMap< const ConceptDef >::prepend().

◆ operator[]() [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 >>
Ptr& LinkedRefMap< T, Hash, KeyEqual, Map >::operator[] ( size_t  pos)
inline

在文件 linkedmap.h364 行定义.

364 { return m_entries[pos]; }

◆ operator[]() [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 >>
const Ptr& LinkedRefMap< T, Hash, KeyEqual, Map >::operator[] ( size_t  pos) const
inline

在文件 linkedmap.h365 行定义.

365 { return m_entries[pos]; }

◆ prepend() [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 >>
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

在文件 linkedmap.h317 行定义.

318  {
319  if (find(k)==nullptr) // new element
320  {
321  std::string key(k ? k : "");
322  m_lookup.insert({key,obj});
323  m_entries.insert(m_entries.begin(),obj);
324  return true;
325  }
326  else // already existing, don't add
327  {
328  return false;
329  }
330  }

被这些函数引用 FileDefImpl::addIncludedUsingDirectives().

◆ prepend() [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 >>
bool LinkedRefMap< T, Hash, KeyEqual, Map >::prepend ( const QCString key,
T *  obj 
)
inline

在文件 linkedmap.h332 行定义.

333  {
334  if (find(key)==nullptr) // new element
335  {
336  m_lookup.insert({key.str(),obj});
337  m_entries.insert(m_entries.begin(),obj);
338  return true;
339  }
340  else // already existing, don't add
341  {
342  return false;
343  }
344  }

◆ rbegin() [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 >>
reverse_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::rbegin ( )
inline

在文件 linkedmap.h370 行定义.

370 { return m_entries.rbegin(); }

◆ rbegin() [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 >>
const_reverse_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::rbegin ( ) const
inline

在文件 linkedmap.h372 行定义.

372 { return m_entries.crbegin(); }

◆ rend() [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 >>
reverse_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::rend ( )
inline

在文件 linkedmap.h371 行定义.

371 { return m_entries.rend(); }

◆ rend() [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 >>
const_reverse_iterator LinkedRefMap< T, Hash, KeyEqual, Map >::rend ( ) const
inline

在文件 linkedmap.h373 行定义.

373 { return m_entries.crend(); }

◆ size()

类成员变量说明

◆ m_entries

◆ m_lookup

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 >>
Map LinkedRefMap< T, Hash, KeyEqual, Map >::m_lookup
private

该类的文档由以下文件生成:
LinkedRefMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:231
QCString::str
std::string str() const
Definition: qcstring.h:442
LinkedRefMap::m_lookup
Map m_lookup
Definition: linkedmap.h:384
LinkedRefMap::m_entries
Vec m_entries
Definition: linkedmap.h:385
LinkedRefMap::find
const T * find(const std::string &key) const
find an object given the key.
Definition: linkedmap.h:243