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

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

#include <linkedmap.h>

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

Public 类型

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

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)
 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. 更多...
 
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). 更多...
 
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. 更多...
 
template<class... Args>
T * prepend (const QCString &key, Args &&... args)
 
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 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.

在文件 linkedmap.h35 行定义.

成员类型定义说明

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

在文件 linkedmap.h54 行定义.

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

在文件 linkedmap.h56 行定义.

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

在文件 linkedmap.h53 行定义.

◆ 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 LinkedMap< T, Hash, KeyEqual, Map >::Ptr = std::unique_ptr<T>

在文件 linkedmap.h51 行定义.

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

在文件 linkedmap.h55 行定义.

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

在文件 linkedmap.h52 行定义.

成员函数说明

◆ add() [1/4]

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.

在文件 linkedmap.h103 行定义.

106  {
107  std::string key = k.str();
108  T *result = find(key);
109  if (result==nullptr)
110  {
111  Ptr ptr = std::make_unique<T>(k,std::forward<Args>(args)...);
112  result = ptr.get();
113  m_lookup.insert({key,result});
114  m_entries.push_back(std::move(ptr));
115  }

被这些函数引用 SectionManager::add(), addEnumValuesToEnums(), UsedDir::addFileDep(), addInstance(), HtmlHelpIndex::addItem(), addLocalObjCMethod(), ClassDefImpl::addMembersToTemplateInstance(), addRelatedPage(), DirDefImpl::addUsesDependency(), addVariableToClass(), addVariableToFile(), buildDefineList(), buildExampleList(), buildGroupListFiltered(), TagFileParser::buildLists(), buildNamespaceList(), DirDefImpl::createNewDir(), findDefineDocumentation(), findEnums(), findMember(), findUsingDeclImports(), NamespaceDefImpl::insertMember(), GroupDefImpl::insertMember(), ClassDefImpl::internalInsertMember(), ClassDefImpl::mergeCategory(), ClassDefImpl::mergeMembers(), readDir(), readFileOrDirectory(), SectionManager::replace() , 以及 resolveClassNestingRelations().

◆ add() [2/4]

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.

在文件 linkedmap.h136 行定义.

137  {
138  std::string key = k.str();
139  T *result = find(key);
140  if (result==nullptr)
141  {
142  result = ptr.get();
143  m_lookup.insert({key,result});
144  m_entries.push_back(std::move(ptr));
145  }
146  return result;
147  }

◆ add() [3/4]

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 QCString k,
Args &&...  args 
)
inline

在文件 linkedmap.h118 行定义.

124  {
125  T *result = find(k);
126  if (result==nullptr)
127  {
128  std::string key(k ? k : "");
129  result = ptr.get();
130  m_lookup.insert({key,result});

◆ add() [4/4]

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 QCString k,
Ptr &&  ptr 
)
inline

在文件 linkedmap.h149 行定义.

154  {
155  T *result = find(k);
156  if (result==nullptr)
157  {
158  std::string key(k ? k : "");
159  Ptr ptr = std::make_unique<T>(key.c_str(),std::forward<Args>(args)...);
160  result = ptr.get();

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

在文件 linkedmap.h216 行定义.

218 :
219 

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

在文件 linkedmap.h225 行定义.

被这些函数引用 cleanUpDoxygen() , 以及 clearAll().

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

在文件 linkedmap.h196 行定义.

199  { return m_entries[pos]; }
200  const Ptr &operator[](size_t pos) const { return m_entries[pos]; }
201  iterator begin() { return m_entries.begin(); }
202  iterator end() { return m_entries.end(); }
203  const_iterator begin() const { return m_entries.cbegin(); }
204  const_iterator end() const { return m_entries.cend(); }
205  reverse_iterator rbegin() { return m_entries.rbegin(); }
206  reverse_iterator rend() { return m_entries.rend(); }
207  const_reverse_iterator rbegin() const { return m_entries.crbegin(); }
208  const_reverse_iterator rend() const { return m_entries.crend(); }
209  bool empty() const { return m_entries.empty(); }
210  size_t size() const { return m_entries.size(); }

被这些函数引用 GroupDefImpl::removeMember().

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

在文件 linkedmap.h215 行定义.

218 :
219 

被这些函数引用 DirDefImpl::computeDependencies(), UsedDir::sort() , 以及 ClassDefImpl::sortAllMembersList().

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

在文件 linkedmap.h217 行定义.

218 :
219 

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

A non-const wrapper for find() const

在文件 linkedmap.h82 行定义.

82  {
83  return const_cast<T*>(static_cast<const LinkedMap&>(*this).find(key));
84  }
85 

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

在文件 linkedmap.h76 行定义.

76  {
77  return const_cast<T*>(static_cast<const LinkedMap&>(*this).find(key));
78  }
79 

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

A non-const wrapper for find() const

在文件 linkedmap.h88 行定义.

91  {

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

在文件 linkedmap.h68 行定义.

70  {
71  return const_cast<T*>(static_cast<const LinkedMap&>(*this).find(key));
72  }

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

A non-const wrapper for find() const

在文件 linkedmap.h94 行定义.

94  {
95  std::string key(k ? k : "");
96  Ptr ptr = std::make_unique<T>(QCString(k),std::forward<Args>(args)...);
97  result = ptr.get();

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

在文件 linkedmap.h60 行定义.

64  {

被这些函数引用 LinkedMap< DirDef >::add(), addClassToGroups(), addConceptToGroups(), addDirToGroups(), addEnumValuesToEnums(), addExampleToGroups(), addGroupToGroups(), TagFileParser::addIncludes(), addMemberFunction(), addMemberToGroups(), addNamespaceToGroups(), addRelatedPage(), DefinitionImpl::addSectionsToDefinition(), DirDefImpl::addUsesDependency(), addVariableToClass(), addVariableToFile(), buildDirectories(), buildFileList(), buildGroupListFiltered(), buildNamespaceList(), buildScopeFromQualifiedName(), computePageRelations(), DirDefImpl::createNewDir(), DocAnchor::DocAnchor(), DocHtmlCaption::DocHtmlCaption(), DocRef::DocRef(), LinkedMap< DirDef >::find(), findDefineDocumentation(), DocParser::findDocsForMemberOrCompound(), findEnumDocumentation(), UsedDir::findFilePair(), findGlobalMember(), findMainPage(), findMember(), findUsedClassesForClass(), findUsingDeclImports(), findUsingDirectives(), PerlModGenerator::generatePerlModForPage(), generateXMLForPage(), VhdlDocGen::getClass(), getClass(), getConcept(), getDefs(), ClassDefImpl::getMemberByName(), getResolvedNamespace(), getTemplateArgumentsFromName(), ClassDefImpl::insertTemplateInstance(), isVarWithConstructor(), ClassDefImpl::mergeCategory(), ClassDefImpl::mergeMembers(), DocXRefItem::parse(), DocSection::parse(), DocSecRefItem::parse(), DocRoot::parse(), LinkedMap< DirDef >::prepend(), GroupDefImpl::removeMember(), SectionManager::replace(), resolveLink(), resolveRef(), resolveTypeDef(), resolveUserReferences(), showFileDefMatches(), PageDefImpl::writeDocumentation(), writeGroupTreeNode() , 以及 GroupDefImpl::writePageDocumentation().

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

在文件 linkedmap.h212 行定义.

213 {

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

在文件 linkedmap.h213 行定义.

213 {

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

在文件 linkedmap.h166 行定义.

169  {
170  T *result = find(key);
171  if (result==nullptr)
172  {
173  Ptr ptr = std::make_unique<T>(key,std::forward<Args>(args)...);
174  result = ptr.get();
175  m_lookup.insert({key.str(),result});
176  m_entries.push_front(std::move(ptr));
177  }
178  return result;

◆ 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 >>
template<class... Args>
T* LinkedMap< T, Hash, KeyEqual, Map >::prepend ( const QCString key,
Args &&...  args 
)
inline

在文件 linkedmap.h181 行定义.

184  {
185  auto it = m_lookup.find(key.str());
186  if (it!=m_lookup.end())
187  {
188  auto vecit = std::find_if(m_entries.begin(),m_entries.end(),[obj=it->second](auto &el) { return el.get()==obj; });
189  if (vecit!=m_entries.end()) // should always be true
190  {
191  m_entries.erase(vecit);
192  m_lookup.erase(it);

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

在文件 linkedmap.h218 行定义.

218 :
219 

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

在文件 linkedmap.h220 行定义.

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

在文件 linkedmap.h219 行定义.

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

在文件 linkedmap.h221 行定义.

◆ size()

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 >>
size_t LinkedMap< T, Hash, KeyEqual, Map >::size ( ) const
inline

在文件 linkedmap.h223 行定义.

被这些函数引用 computeClassRelations() , 以及 HtmlHelpIndex::size().

类成员变量说明

◆ 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 >>
Vec LinkedMap< T, Hash, KeyEqual, Map >::m_entries
private

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

该类的文档由以下文件生成:
LinkedMap::const_iterator
typename Vec::const_iterator const_iterator
Definition: linkedmap.h:54
LinkedMap::const_reverse_iterator
typename Vec::const_reverse_iterator const_reverse_iterator
Definition: linkedmap.h:56
LinkedMap::empty
bool empty() const
Definition: linkedmap.h:222
QCString::str
std::string str() const
Definition: qcstring.h:442
LinkedMap::Ptr
std::unique_ptr< T > Ptr
Definition: linkedmap.h:51
LinkedMap::reverse_iterator
typename Vec::reverse_iterator reverse_iterator
Definition: linkedmap.h:55
LinkedMap::operator[]
Ptr & operator[](size_t pos)
Definition: linkedmap.h:212
LinkedMap::begin
iterator begin()
Definition: linkedmap.h:214
LinkedMap::iterator
typename Vec::iterator iterator
Definition: linkedmap.h:53
LinkedMap::rbegin
reverse_iterator rbegin()
Definition: linkedmap.h:218
LinkedMap::find
const T * find(const std::string &key) const
Find an object given the key.
Definition: linkedmap.h:60
LinkedMap::rend
reverse_iterator rend()
Definition: linkedmap.h:219
LinkedMap::end
iterator end()
Definition: linkedmap.h:215
LinkedMap::m_entries
Vec m_entries
Definition: linkedmap.h:234
LinkedMap
Container class representing a vector of objects with keys.
Definition: linkedmap.h:35
LinkedMap::m_lookup
Map m_lookup
Definition: linkedmap.h:233
LinkedMap::size
size_t size() const
Definition: linkedmap.h:223
QCString
This is an alternative implementation of QCString.
Definition: qcstring.h:108