TreeApi Interface
Provides various functions for interacting with TreeNodes.
For more information about our API support guarantees, see here.
Signature
/** @sealed */
export interface TreeApi extends TreeNodeApi
Extends: TreeNodeApi
Remarks
This type should only be used via the public Tree
export.
Properties
Property | Modifiers | Type | Description |
---|---|---|---|
runTransaction | readonly |
RunTransaction | Run a transaction. |
Methods
Method | Return Type | Description |
---|---|---|
contains(node, other) | boolean | Check if the subtree defined by node contains other . |
Property Details
runTransaction
Run a transaction.
For more information about our API support guarantees, see here.
Signature
readonly runTransaction: RunTransaction;
Type: RunTransaction
Method Details
contains
Check if the subtree defined by node
contains other
.
For more information about our API support guarantees, see here.
Signature
contains(node: TreeNode, other: TreeNode): boolean;
Remarks
This includes direct and indirect children: as long as node
is an ancestor of other
(occurs in its parentage chain), this returns true, regardless of the number of levels of the tree between.
node
is considered to contain itself, so the case where node === other
returns true.
This is handy when checking if moving node
into other
would create a cycle and thus is invalid.
This check walks the parents of other
looking for node
, and thus runs in time proportional to the depth of child in the tree.
Parameters
Parameter | Type | Description |
---|---|---|
node | TreeNode | |
other | TreeNode |
Returns
true if other
is an inclusive descendant of node
, and false otherwise.
Return type: boolean