AbstractNode class
An abstract node in a tree.
AbstractNode has as notion of depth, attachment, and parent, but does not have a model for children.
When a subclass is changing the parent of a child, it should call either
parent.adoptChild(child)
or parent.dropChild(child)
as appropriate.
Subclasses can expose an API for manipulating the tree if desired (e.g. a
setter for a child
property, or an add()
method to manipulate a list).
The current parent node is exposed by the parent property.
The current attachment state is exposed by attached. The root of any tree that is to be considered attached should be manually attached by calling attach. Other than that, the attach and detach methods should not be called directly; attachment is managed automatically by the aforementioned adoptChild and dropChild methods.
Subclasses that have children must override attach and detach as described in the documentation for those methods.
Nodes always have a depth greater than their ancestors'. There's no guarantee regarding depth between siblings. The depth of a node is used to ensure that nodes are processed in depth order. The depth of a child can be more than one greater than the depth of the parent, because the depth values are never decreased: all that matters is that it's greater than the parent. Consider a tree with a root node A, a child B, and a grandchild C. Initially, A will have depth 0, B depth 1, and C depth 2. If C is moved to be a child of A, sibling of B, then the numbers won't change. C's depth will still be 2. The depth is automatically maintained by the adoptChild and dropChild methods.
- Implementers
Constructors
Properties
- attached → bool
-
Whether this node is in a tree whose root is attached to something. [...]
read-only
- depth → int
-
The depth of this node in the tree. [...]
read-only
- owner → Object
-
The owner for this node (null if unattached). [...]
read-only
- parent → AbstractNode
-
The parent of this node in the tree.
read-only
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
adoptChild(
covariant AbstractNode child) → void -
Mark the given node as being a child of this node. [...]
@mustCallSuper, @protected
-
attach(
covariant Object owner) → void -
Mark this node as attached to the given owner. [...]
@mustCallSuper
-
detach(
) → void -
Mark this node as detached. [...]
@mustCallSuper
-
dropChild(
covariant AbstractNode child) → void -
Disconnect the given node from this node. [...]
@mustCallSuper, @protected
-
redepthChild(
AbstractNode child) → void -
Adjust the depth of the given
child
to be greater than this node's own depth. [...]@protected -
redepthChildren(
) → void - Adjust the depth of this node's children, if any. [...]
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited