Constructor
(abstract) new AbstractNode()
- Source:
Methods
addChild(node)
Adds a child to this node, preserving the invariants described at the top of this document. Specifically:
The last two invariants are preserved by calling removeChild or removeParent on any existing children or parents that violate the invariants.
A node x cannot be the child of a node y if they have the same host.
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode | The child node to add |
- Source:
addParent(node)
Adds a parent to this node, preserving the invariants described at the top of this document. Specifically:
The last two invariants are preserved by calling removeChild or removeParent on any existing children or parents that violate the invariants.
A node x cannot be the parent of a node y if they have the same host.
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode | The node to add as a parent to this |
- Source:
clearChildren()
- Source:
clearFamily()
- Source:
clearParents()
- Source:
getChildByHost(host) → {AbstractNode}
Parameters:
Name | Type | Description |
---|---|---|
host |
String | The target host |
- Source:
Returns:
- Type
- AbstractNode
getChildren() → {Array.<AbstractNode>}
Returns children of this node as an array
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of children.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getConnections() → {Array.<AbstractNode>}
Returns the nodes this one is connected to as an array. In the context of this function, a node is said to be connected to this one if it's the previous node, the next node, a parent, or a child. Note that if prev or next is a head or tail or null, it will still be returned.
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of connections.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getFamily() → {Array.<AbstractNode>}
Returns the family nodes of this node as an array.
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of family nodes.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getFamily() → {Array.<AbstractNode>}
Returns family of this node as an array
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of family.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getHost() → {String}
- Source:
Returns:
- Type
- String
getId() → {Number}
- Source:
Returns:
- Type
- Number
getNext() → {AbstractNode}
- Source:
Returns:
- Type
- AbstractNode
getParentByHost(host) → {AbstractNode}
Parameters:
Name | Type | Description |
---|---|---|
host |
String | The target host |
- Source:
Returns:
- Type
- AbstractNode
getParents() → {Array.<AbstractNode>}
Returns parents of this node as an array
This function makes no guarantees about the ordering of nodes in the array returned. Also note that a new array is created to prevent modification of the underlying private data structure, so this function takes linear rather than constant time on the number of parents.
- Source:
Returns:
- Type
- Array.<AbstractNode>
getPrev() → {AbstractNode}
- Source:
Returns:
- Type
- AbstractNode
hasChildren() → {Boolean}
- Source:
Returns:
- Type
- Boolean
hasFamily() → {Boolean}
- Source:
Returns:
- Type
- Boolean
hasParents() → {Boolean}
- Source:
Returns:
- Type
- Boolean
insertNext(node)
Inserts a node after this one, preserving the invariants described at the top of this document. The node to insert is first removed from its previous location (i.e by calling AbstractNode#remove). You cannot insert a node after a tail node.
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode | The node to insert |
- Source:
insertPrev(node)
Inserts a node before this one, preserving the invariants described at the top of this document. The node to insert is first removed from its previous location (i.e by calling AbstractNode#remove). You cannot insert a node before a head node.
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode | The node to insert |
- Source:
isDummy() → {Boolean}
- Source:
Returns:
- Type
- Boolean
isHead() → {Boolean}
- Source:
Returns:
- Type
- Boolean
isTail() → {Boolean}
- Source:
Returns:
- Type
- Boolean
remove()
Removes a node, preserving the invariants described at the top of this document. This method will also remove all connections to the node. Head and tail nodes cannot be removed. This function does nothing if it is called on a node that had already been removed.
Because this method essentially removes all links to and from the node, be careful when using this inside a loop. For example, consider the following code:
var node = this.getHead(host).getNext(); while (!curr.isTail()) { curr.remove(); curr = curr.getNext(); // sets curr to null! curr.getNext() == null after removal }
- Source:
removeChild(node)
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode |
- Source:
removeChildByHost(host)
Parameters:
Name | Type | Description |
---|---|---|
host |
String |
- Source:
removeFamily(node)
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode |
- Source:
removeParent(node)
Parameters:
Name | Type | Description |
---|---|---|
node |
AbstractNode |
- Source:
removeParentByHost(host)
Parameters:
Name | Type | Description |
---|---|---|
host |
String |
- Source: