My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Attributes | Friends | List of all members
SDict< T > Class Template Reference

#include <sortdict.h>

Classes

class  Iterator
 
class  IteratorDict
 

Public Member Functions

 SDict (int size=17, bool caseSensitive=TRUE)
 
virtual ~SDict ()
 
void append (const char *key, const T *d)
 
void prepend (const char *key, const T *d)
 
bool remove (const char *key)
 
T * take (const char *key)
 
void sort ()
 
void inSort (const char *key, const T *d)
 
void insertAt (int i, const char *key, const T *d)
 
void setAutoDelete (bool val)
 
T * find (const char *key)
 
T * find (const QCString &key)
 
T * find (const QString &key)
 
int findAt (const QCString &key)
 
T * operator[] (const char *key) const
 
T * at (uint i)
 
virtual int compareValues (const T *item1, const T *item2) const
 
void clear ()
 
int count () const
 

Private Attributes

SList< T > * m_list
 
QDict< T > * m_dict
 
int m_sizeIndex
 

Friends

class Iterator
 
class IteratorDict
 

Detailed Description

template<class T>
class SDict< T >

Ordered dictionary of elements of type T. Internally uses a QList<T> and a QDict<T>.

Definition at line 73 of file sortdict.h.

Constructor & Destructor Documentation

template<class T>
SDict< T >::SDict ( int  size = 17,
bool  caseSensitive = TRUE 
)
inline

Create an ordered dictionary.

Parameters
sizeThe size of the dictionary. Should be a prime number for best distribution of elements.
caseSensitiveindicated whether the keys should be sorted in a case sensitive way.

Definition at line 111 of file sortdict.h.

{
m_list = new SList<T>(this);
#if AUTORESIZE
while ((uint)size>SDict_primes[m_sizeIndex]) m_sizeIndex++;
m_dict = new QDict<T>(SDict_primes[m_sizeIndex],caseSensitive);
#else
m_dict = new QDict<T>(size,caseSensitive);
#endif
}
template<class T>
virtual SDict< T >::~SDict ( )
inlinevirtual

Destroys the dictionary

Definition at line 123 of file sortdict.h.

{
delete m_list;
delete m_dict;
}

Member Function Documentation

template<class T>
void SDict< T >::append ( const char *  key,
const T *  d 
)
inline

Appends an element to the dictionary. The element is owned by the dictionary.

Parameters
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See Also
find()

Definition at line 135 of file sortdict.h.

Referenced by GroupDef::addClass(), addClassToContext(), addDirsAsGroups(), TagFileParser::addDocAnchors(), addEnumValuesToEnums(), GroupDef::addExample(), DotManager::addFigure(), UsedDir::addFileDep(), DocSets::addIndexItem(), PageDef::addInnerCompound(), NamespaceDef::addInnerCompound(), addInterfaceOrServiceToServiceOrSingleton(), HtmlHelpIndex::addItem(), DotManager::addMap(), ClassDef::addMembersToTemplateInstance(), addMethodToClass(), GroupDef::addNamespace(), GroupDef::addPage(), addRelatedPage(), Definition::addSectionsToDefinition(), Definition::addSourceReferencedBy(), Definition::addSourceReferences(), DotManager::addSVGConversion(), DotManager::addSVGObject(), ClassDef::addTypeConstraint(), NamespaceDef::addUsingDeclaration(), FileDef::addUsingDeclaration(), NamespaceDef::addUsingDirective(), FileDef::addUsingDirective(), addVariableToClass(), addVariableToFile(), SearchIndexList::append(), buildFunctionList(), buildGroupListFiltered(), DirDef::createNewDir(), createTagLessInstance(), MemberDef::deepCopy(), Definition::Definition(), DocAnchor::DocAnchor(), DocHtmlCaption::DocHtmlCaption(), findClassRelation(), findDefineDocumentation(), findEnums(), findMainPage(), findMember(), findTemplateInstanceRelation(), findUsedClassesForClass(), findUsingDeclarations(), GenericsSDict::insert(), NamespaceDef::insertClass(), FileDef::insertClass(), RefList::insertIntoList(), NamespaceDef::insertMember(), GroupDef::insertMember(), NamespaceDef::insertNamespace(), FileDef::insertNamespace(), ClassDef::internalInsertMember(), ClassDef::mergeCategory(), ClassDef::mergeMembers(), DocSection::parse(), DocSecRefItem::parse(), processBlocks(), SearchIndexExternal::setCurrentDoc(), MemberDef::setSectionList(), unmarshalMemberLists(), unmarshalMemberSDict(), unmarshalSectionDict(), writeDotDirDepGraph(), writeOneLineHeaderOrRuler(), and VhdlDocGen::writePlainVHDLDeclarations().

{
m_list->append(d);
m_dict->insert(key,d);
#if AUTORESIZE
{
}
#endif
}
template<class T>
T* SDict< T >::at ( uint  i)
inline

Returns the item at position i in the sorted dictionary

Definition at line 258 of file sortdict.h.

Referenced by Definition::_writeSourceRefList(), GroupDef::addClass(), and writeExample().

{
return m_list->at(i);
}
template<class T>
void SDict< T >::clear ( )
inline

Clears the dictionary. Will delete items if setAutoDelete() was set to TRUE.

See Also
setAutoDelete

Definition at line 276 of file sortdict.h.

Referenced by clearAll(), and VhdlDocGen::writePlainVHDLDeclarations().

{
m_list->clear();
m_dict->clear();
}
template<class T>
virtual int SDict< T >::compareValues ( const T *  item1,
const T *  item2 
) const
inlinevirtual

Function that is used to compare two items when sorting. Overload this to properly sort items.

See Also
inSort()

Reimplemented in NamespaceSDict, DirSDict, GroupSDict, SearchIndexList, MemberSDict, FilePairDict, MemberNameInfoSDict, PageSDict, ClassSDict, IndexFieldSDict, MemberNameSDict, SortedRefItems, and ExampleSDict.

Definition at line 267 of file sortdict.h.

{
return item1!=item2;
}
template<class T>
int SDict< T >::count ( ) const
inline
template<class T>
T* SDict< T >::find ( const char *  key)
inline

Looks up a compound given its key.

Parameters
keyThe key to identify this element.
Returns
The requested compound or zero if it cannot be found.
See Also
append()

Definition at line 232 of file sortdict.h.

Referenced by accessibleViaUsingNamespace(), GroupDef::addClass(), addClassToGroups(), addDirToGroups(), addEnumValuesToEnums(), MemberDef::addExample(), ClassDef::addExample(), addExampleToGroups(), DotManager::addFigure(), addGroupToGroups(), FileDef::addIncludedUsingDirectives(), DocSets::addIndexItem(), HtmlHelpIndex::addItem(), DotManager::addMap(), ClassDef::addMembersToTemplateInstance(), addMemberToGroups(), GroupDef::addNamespace(), addNamespaceToGroups(), addRelatedPage(), Definition::addSectionsToDefinition(), Definition::addSourceReferencedBy(), Definition::addSourceReferences(), DotManager::addSVGConversion(), DotManager::addSVGObject(), NamespaceDef::addUsingDeclaration(), FileDef::addUsingDeclaration(), NamespaceDef::addUsingDirective(), FileDef::addUsingDirective(), addVariableToClass(), addVariableToFile(), buildDirectories(), buildFileList(), buildFunctionList(), buildGroupListFiltered(), buildScopeFromQualifiedName(), computePageRelations(), VhdlDocGen::computeVhdlComponentRelations(), DirDef::createNewDir(), DotNode::deleteNode(), DocAnchor::DocAnchor(), DocHtmlCaption::DocHtmlCaption(), DocRef::DocRef(), GenericsSDict::find(), SDict< Example >::findAt(), findClassRelation(), findDefineDocumentation(), findDocsForMemberOrCompound(), findEnumDocumentation(), UsedDir::findFilePair(), findGlobalMember(), NamespaceDef::findInnerCompound(), ClassDef::findInnerCompound(), findMainPage(), findMember(), findUsedClassesForClass(), findUsingDeclarations(), findUsingDeclImports(), findUsingDirectives(), generateDocbookForPage(), PerlModGenerator::generatePerlModForPage(), generateXMLForPage(), VhdlDocGen::getClass(), getClass(), getDefs(), NamespaceDef::getMemberByName(), ClassDef::getMemberByName(), getResolvedNamespace(), MemberDef::getSectionList(), getTemplateArgumentsFromName(), GenericsSDict::insert(), NamespaceDef::insertClass(), RefList::insertIntoList(), NamespaceDef::insertNamespace(), FileDef::insertNamespace(), ClassDef::internalInsertMember(), isVarWithConstructor(), mergeCategories(), ClassDef::mergeCategory(), ClassDef::mergeMembers(), DocSection::parse(), DocSecRefItem::parse(), DocRoot::parse(), processBlocks(), GroupDef::removeMember(), resolveRef(), resolveTypeDef(), resolveUserReferences(), SearchIndexExternal::setCurrentDoc(), transferFunctionReferences(), PageDef::writeDocumentation(), writeOneLineHeaderOrRuler(), GroupDef::writePageDocumentation(), and VhdlDocGen::writePlainVHDLDeclarations().

{
return m_dict->find(key);
}
template<class T>
T* SDict< T >::find ( const QCString &  key)
inline

Definition at line 236 of file sortdict.h.

{
return m_dict->find(key);
}
template<class T>
T* SDict< T >::find ( const QString &  key)
inline

Definition at line 240 of file sortdict.h.

{
return m_dict->find(key);
}
template<class T>
int SDict< T >::findAt ( const QCString &  key)
inline

Definition at line 244 of file sortdict.h.

Referenced by GroupDef::addClass().

{
T *item = find(key);
if (item==0) return -1;
return m_list->find(item);
}
template<class T>
void SDict< T >::insertAt ( int  i,
const char *  key,
const T *  d 
)
inline

Definition at line 209 of file sortdict.h.

Referenced by GroupDef::addClass().

{
m_list->insert(i,d);
m_dict->insert(key,d);
#if AUTORESIZE
{
}
#endif
}
template<class T>
void SDict< T >::inSort ( const char *  key,
const T *  d 
)
inline

Inserts a compound into the dictionary in a sorted way.

Parameters
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See Also
find()

Definition at line 197 of file sortdict.h.

Referenced by GroupDef::addClass(), MemberDef::addExample(), ClassDef::addExample(), ClassDef::addInnerCompound(), GroupDef::addNamespace(), buildExampleList(), buildNamespaceList(), buildScopeFromQualifiedName(), findUsingDirectives(), NamespaceDef::insertClass(), FileDef::insertClass(), NamespaceDef::insertNamespace(), FileDef::insertNamespace(), and unmarshalExampleSDict().

{
m_list->inSort(d);
m_dict->insert(key,d);
#if AUTORESIZE
{
}
#endif
}
template<class T>
T* SDict< T >::operator[] ( const char *  key) const
inline

Equavalent to find().

Definition at line 252 of file sortdict.h.

{
return m_dict->find(key);
}
template<class T>
void SDict< T >::prepend ( const char *  key,
const T *  d 
)
inline

Prepends an element to the dictionary. The element is owned by the dictionary.

Parameters
keyThe unique key to use to quicky find the item later on.
dThe compound to add.
See Also
find()

Definition at line 153 of file sortdict.h.

Referenced by FileDef::addIncludedUsingDirectives().

{
m_list->prepend(d);
m_dict->insert(key,d);
#if AUTORESIZE
{
}
#endif
}
template<class T>
bool SDict< T >::remove ( const char *  key)
inline

Remove an item from the dictionary

Definition at line 166 of file sortdict.h.

Referenced by GroupDef::removeMember().

{
T *item = m_dict->take(key);
return item ? m_list->remove(item) : FALSE;
}
template<class T>
void SDict< T >::setAutoDelete ( bool  val)
inline
template<class T>
void SDict< T >::sort ( )
inline

Sorts the members of the dictionary. First appending a number of members and then sorting them is faster (O(NlogN) than using inSort() for each member (O(N^2)).

Definition at line 188 of file sortdict.h.

Referenced by Definition::_writeSourceRefList(), buildCompleteMemberLists(), buildDirectories(), createJavascriptSearchIndex(), generateOutput(), RefList::generatePage(), MemberListContext::MemberListContext(), parseInput(), UsedDir::sort(), NamespaceDef::sortMemberLists(), ClassDef::sortMemberLists(), and HtmlHelpIndex::writeFields().

{
m_list->sort();
}
template<class T>
T* SDict< T >::take ( const char *  key)
inline

Take an item out of the dictionary without deleting it

Definition at line 173 of file sortdict.h.

{
T *item = m_dict->take(key);
if (item)
{
int i = m_list->find(item);
m_list->take(i);
}
return item;
}

Friends And Related Function Documentation

template<class T>
friend class Iterator
friend

Definition at line 289 of file sortdict.h.

template<class T>
friend class IteratorDict
friend

Definition at line 353 of file sortdict.h.

Member Data Documentation

template<class T>
QDict<T>* SDict< T >::m_dict
private
template<class T>
SList<T>* SDict< T >::m_list
private
template<class T>
int SDict< T >::m_sizeIndex
private

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