ALox  V. 2402 R. 0
Home ALox for C++ ALox for C# ALox for Java Download
Public Fields | Public Methods | List of all members
StringTree< T >.Node Class Reference
Collaboration diagram for StringTree< T >.Node:
[legend]

Class Description

The internal, protected data structure implementing a node of the tree. This class is not accessible from outside. Instead, inner class Cursor, which represents node objects, provides an indirect interface to the values of this class.

Public Fields

HashMap< String, Nodechildren
 
Node parent
 
value
 

Public Methods

 Node (Node _parent)
 
Node createChild (String childName, char separator)
 
Node createChildNoCheck (String childName)
 
int depth ()
 
Node getChild (String childName, char separator)
 
Node getOrCreateChild (String childName, char separator, boolean[] wasCreated)
 
boolean isRoot ()
 

Constructor & Destructor Documentation

◆ Node()

Node ( Node  _parent)

Constructor.

Parameters
_parentThe parent of this node.

Member Function Documentation

◆ createChild()

Node createChild ( String  childName,
char  separator 
)

Creates and returns a child node. If a node already exists, nothing is done and null is returned as this is considered an error.

Parameters
childNameThe name of the child
separatorThe path separator (used only in debug mode to check file name).
Returns
Pointer to the newly created child in case of success. null if a child with the given name already existed.

◆ createChildNoCheck()

Node createChildNoCheck ( String  childName)

Non-checking version of createChild. Must be used only if it is assured that no child with that name exists, yet.

Parameters
childNameThe name of the child to be created and inserted
Returns
A pointer to the newly created child node.

◆ depth()

int depth ( )

Recursively calculates the depth of a node.

Returns
The depth of the this node.

◆ getChild()

Node getChild ( String  childName,
char  separator 
)

Returns a child node identified by parameter childName. If the child is not found or is illegal (empty, "." or ".." or contain a separator character), null is returned. In debug compilations, an ALIB_DBG.WARNING is reported on illegal child names.

Parameters
childNameThe name of the child
separatorThe path separator.
Returns
The child node found, null on failure.

◆ getOrCreateChild()

Node getOrCreateChild ( String  childName,
char  separator,
boolean[]  wasCreated 
)

Searches and - if no existent - creates a child node.
If a child needs to be created, childName is first checked to not equal to "." or ".." and that it does not contain the separation character. If it does, still true is returned and with null for the new child. Furthermore, an ALIB_DBG.WARNING is reported.

Parameters
childNameThe name of the child
separatorThe path separator.
[out]wasCreatedWill be set to true if the child did not exist and was created. To false otherwise.
Returns
A pair of the child node found or created and a boolean which is true when the child was created and false when it was already existing.

◆ isRoot()

boolean isRoot ( )

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

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

Member Data Documentation

◆ children

HashMap<String, Node> children

Child nodes.

◆ parent

Node parent

Parent node.

◆ value

T value

The template type value.


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