ReferenceTree
public class ReferenceTree
Mutable Tree structure.
-
Error thrown when doing bad things to a
See moreReferenceTree
objects.Declaration
Swift
public enum Error : Swift.Error
-
Parent
MutableTree
. The root of a tree has no parent.Declaration
Swift
public weak var parent: ReferenceTree?
-
Children
MutableTree
objects.Declaration
Swift
public var children: [ReferenceTree]
-
Declaration
Swift
public var isLeaf: Bool { get }
Return Value
true
if there are no children. Otherwise,false
. -
All leaves.
Declaration
Swift
public var leaves: [ReferenceTree] { get }
-
Declaration
Swift
public var isContainer: Bool { get }
Return Value
true
if there is at least one child. Otherwise,false
. -
Declaration
Swift
public var isRoot: Bool { get }
Return Value
true
if there is no parent. Otherwise,false
. -
Declaration
Swift
public var root: ReferenceTree { get }
Return Value
true
if there is no parent. Otherwise,false
. -
Array of all MutableTree objects between (and including)
self
up toroot
.Declaration
Swift
public var pathToRoot: [ReferenceTree] { get }
-
Height of node.
Declaration
Swift
public var height: Int { get }
-
Height of containing tree.
Declaration
Swift
public var heightOfTree: Int { get }
-
Depth of node.
Declaration
Swift
public var depth: Int { get }
-
Create a
ReferenceTree
.Declaration
Swift
public init(parent: ReferenceTree? = nil, children: [ReferenceTree] = [])
-
Add the given
node
tochildren
.Declaration
Swift
public func addChild(_ node: ReferenceTree)
-
Append the given
nodes
tochildren
.Declaration
Swift
public func addChildren(_ nodes: [ReferenceTree])
-
Insert the given
node
at the givenindex
ofchildren
.Declaration
Swift
public func insertChild(_ node: ReferenceTree, at index: Int) throws
-
Remove the given
node
fromchildren
.Declaration
Swift
public func removeChild(_ node: ReferenceTree) throws
-
Remove the node at the given
index
.Declaration
Swift
public func removeChild(at index: Int) throws
-
Declaration
Swift
public func hasChild(_ child: ReferenceTree) -> Bool
Return Value
true
if the given node is contained herein. Otherwise,false
. -
Declaration
Swift
public func child(at index: Int) -> ReferenceTree?
Return Value
Child node at the given
index
, if present. Otherwise,nil
. -
Declaration
Swift
public func leaf(at index: Int) -> ReferenceTree?
Return Value
Returns the leaf node at the given
index
, if present. Otherwise,nil
. -
Declaration
Swift
public func hasLeaf(_ node: ReferenceTree) -> Bool
Return Value
true
if the given node is a leaf. Otherwise,false
. -
Declaration
Swift
public func hasAncestor(_ node: ReferenceTree) -> Bool
Return Value
true
if the given node is an ancestor. Otherwise,false
. -
Declaration
Swift
public func ancestor(at distance: Int) -> ReferenceTree?
Return Value
Ancestor at the given distance, if present. Otherwise,
nil
. -
Declaration
Swift
public func hasDescendent(_ node: ReferenceTree) -> Bool
Return Value
true
if the given node is a descendent. Otherwise,false
.