ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeBase Struct Reference

Description:

template<typename TAllocator, typename T, typename TNodeHandler, Recycling TRecycling>
struct alib::containers::detail::StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeBase

This is the base class of the internal node type Node. This type implements functionality needed. Derived type Node then only adds the custom value T.

Objects of this type cannot be received directly and all interface is available via public type StringTree::Cursor only, which holds a pointer to an object of this class.

Definition at line 156 of file stringtreebase.inl.

Inheritance diagram for StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeBase:
[legend]
Collaboration diagram for StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeBase:
[legend]

Public Field Index:

NodeList children
 The hook to the doubly linked list of children.
 
uinteger qtyChildren
 The number of children currently stored in this node.
 
- Public Field Index: inherited from BidiNodeBase< NodeBase >
NodeBase * p
 
- Public Field Index: inherited from SidiNodeBase< NodeBase >
NodeBase * n
 
- Public Field Index: inherited from StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeKey
NodeNameUnion name
 
NodeBaseparent
 

Public Method Index:

 NodeBase (const NodeKey &pKey)
 
 NodeBase (NodeBase *pParent, const NameType &pName)
 
strings::TAString< CharacterType, lang::HeapAllocator > & assemblePath (strings::TAString< CharacterType, lang::HeapAllocator > &target, const NodeBase *childNode, const NodeBase *maxParent, CharacterType separatorChar) const
 
uinteger deleteChild (StringTreeBase *tree, NodeBase *child)
 
uinteger deleteChildren (StringTreeBase *tree)
 
int depth () const
 
int distance (const NodeBase *other) const
 
NodeBasefindChild (StringTreeBase *tree, const NameType &childName)
 
template<typename... TArgs>
std::pair< NodeBase *, bool > findOrCreateChild (StringTreeBase *tree, const NameType &childName, TArgs &&... args)
 
bool isRoot () const
 
- Public Method Index: inherited from BidiNodeBase< NodeBase >
 BidiNodeBase () noexcept=default
 Default constructor. (Does not initialize the pointer!)
 
 BidiNodeBase (BidiNodeBase &&) noexcept=default
 Defaulted move constructor.
 
 BidiNodeBase (const BidiNodeBase &)=delete
 
 BidiNodeBase (NodeBase *next, NodeBase *prev) noexcept
 
void addBefore (NodeBase *elem) noexcept
 
void addBehind (NodeBase *elem) noexcept
 
BidiNodeBaseoperator= (BidiNodeBase &&) noexcept=default
 
BidiNodeBaseoperator= (const BidiNodeBase &)=delete
 
NodeBase * prev () const noexcept
 
void prev (BidiNodeBase *previous) noexcept
 
void remove () noexcept
 Unhooks this node from a list.
 
void remove (NodeBase *last) noexcept
 
- Public Method Index: inherited from SidiNodeBase< NodeBase >
 SidiNodeBase () noexcept=default
 Default constructor. (Does not initialize the pointer.)
 
 SidiNodeBase (const SidiNodeBase &)=delete
 
 SidiNodeBase (NodeBase *next) noexcept
 
 SidiNodeBase (SidiNodeBase &&) noexcept=default
 Defaulted move constructor.
 
NodeBase * addBehind (NodeBase *elem) noexcept
 
integer count (SidiNodeBase *end=nullptr) const noexcept
 
bool hasNext () const
 
NodeBase * next () const
 
void next (SidiNodeBase *p)
 
SidiNodeBaseoperator= (const SidiNodeBase &)=delete
 
SidiNodeBaseoperator= (SidiNodeBase &&) noexcept=default
 
bool pointsTo (const SidiNodeBase *elem) const
 
NodeBase * removeNext () noexcept
 
NodeBase * removeRangeBehind (NodeBase *last) noexcept
 
- Public Method Index: inherited from StringTreeBase< TAllocator, T, TNodeHandler, TRecycling >::NodeKey
 NodeKey (NodeBase *pParent, const NameType &pName)
 

Additional Inherited Members

- Public Type Index: inherited from BidiNodeBase< NodeBase >
using FWDNode
 Alias name for an instantiation of the base template.
 

Field Details:

◆ children

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
NodeList children

The hook to the doubly linked list of children.

Definition at line 163 of file stringtreebase.inl.

◆ qtyChildren

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
uinteger qtyChildren

The number of children currently stored in this node.

Definition at line 160 of file stringtreebase.inl.

Constructor(s) / Destructor Details:

◆ NodeBase() [1/2]

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
NodeBase ( const NodeKey & pKey)
inline

Constructor.

Parameters
pKeyThe key portion of the node.

Definition at line 167 of file stringtreebase.inl.

◆ NodeBase() [2/2]

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
NodeBase ( NodeBase * pParent,
const NameType & pName )
inline

Constructor. Custom data is default-initialized.

Parameters
pParentParent node to search a child for.
pNameChild name to search

Definition at line 175 of file stringtreebase.inl.

Method Details:

◆ assemblePath()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
strings::TAString< CharacterType, lang::HeapAllocator > & assemblePath ( strings::TAString< CharacterType, lang::HeapAllocator > & target,
const NodeBase * childNode,
const NodeBase * maxParent,
CharacterType separatorChar ) const
inline

Implementation of TCursor::AssemblePath.

Parameters
targetThe target to append the path to.
childNodeThe (current) child node.
maxParentThe last parent node to travel up to. The root node is designated by nullptr.
separatorCharThe separator character as defined with the template parameter of class StringTree.
Returns
The given AString to allow concatenated operations on it.

Definition at line 349 of file stringtreebase.inl.

◆ deleteChild()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
uinteger deleteChild ( StringTreeBase * tree,
NodeBase * child )
inline

Deletes a given child node.

Note
If the given node is not a child of this node, the behavior is undefined. With debug-builds, in this case an ALib assertion is raised.
Parameters
treeThe tree this node belongs to.
childA pointer to a child of this node that is to be deleted.
Returns
The total number of nodes deleted.

Definition at line 296 of file stringtreebase.inl.

Here is the call graph for this function:

◆ deleteChildren()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
uinteger deleteChildren ( StringTreeBase * tree)
inline

Deletes all child nodes.

Parameters
treeThe tree this node belongs to.
Returns
The number of children that were deleted.

Definition at line 316 of file stringtreebase.inl.

Here is the call graph for this function:

◆ depth()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
int depth ( ) const
inline

Iterates over the parent nodes to the root node and returns this node's depth.

Returns
The depth of this node.

Definition at line 226 of file stringtreebase.inl.

◆ distance()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
int distance ( const NodeBase * other) const
inline

Iterates over the parent nodes and searches given other in the path.

Parameters
otherThe node to calculate the distance to.
Returns
The distance of other to this node. 0 if the nodes are the same. -1 if other was not found.

Definition at line 243 of file stringtreebase.inl.

◆ findChild()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
NodeBase * findChild ( StringTreeBase * tree,
const NameType & childName )
inline

Searches a child with a given name. The name is not checked for ., .. or if separation characters.

Parameters
treeThe tree this node belongs to.
childNameThe name of the child to search.
Returns
The child or nullptr if not found.

Definition at line 193 of file stringtreebase.inl.

Here is the call graph for this function:

◆ findOrCreateChild()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
template<typename... TArgs>
std::pair< NodeBase *, bool > findOrCreateChild ( StringTreeBase * tree,
const NameType & childName,
TArgs &&... args )
inline

Searches a child with a given name, if not found, one is created. The name is not checked for ., .. or if separation characters.

Template Parameters
TArgsTypes of variadic parameters given with parameter args.
Parameters
treeThe tree this node belongs to.
childNameThe name of the child to search.
argsVariadic parameters to be forwarded to the constructor of custom type T in the case a child is created.
Returns
A pair containing an iterator referencing either the element found or the new element added. The bool component is true if the insertion took place and false nothing was changed.

Definition at line 270 of file stringtreebase.inl.

Here is the call graph for this function:

◆ isRoot()

template<typename TAllocator , typename T , typename TNodeHandler , Recycling TRecycling>
bool isRoot ( ) const
inline

Returns true if this is the root node, false otherwise.

Returns
true if this is the root node, false otherwise.

Definition at line 182 of file stringtreebase.inl.


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