@@ -133,7 +133,7 @@ Return the parent of the given object.
133133#### symbolTree.lastInclusiveDescendant(object) ⇒ <code >Object</code >
134134Find the inclusive descendant that is last in tree order of the given object.
135135
136- ` O(n) ` (worst case)
136+ ` O(n) ` (worst case) where n is the depth of the subtree of ` object `
137137
138138** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
139139
@@ -147,7 +147,8 @@ Find the preceding object (A) of the given object (B).
147147An object A is preceding an object B if A and B are in the same tree
148148and A comes before B in tree order.
149149
150- ` O(n) ` (worst case)
150+ ` O(n) ` (worst case) <br >
151+ ` O(1) ` (amortized when walking the entire tree)
151152
152153** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
153154
@@ -163,7 +164,8 @@ Find the following object (A) of the given object (B).
163164An object A is following an object B if A and B are in the same tree
164165and A comes after B in tree order.
165166
166- ` O(n) ` (worst case)
167+ ` O(n) ` (worst case) where n is the amount of objects in the entire tree<br >
168+ ` O(1) ` (amortized when walking the entire tree)
167169
168170** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
169171
@@ -178,7 +180,7 @@ and A comes after B in tree order.
178180#### symbolTree.childrenToArray(parent, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
179181Append all children of the given object to an array.
180182
181- ` O(n) `
183+ ` O(n) ` where n is the amount of children of the given ` parent `
182184
183185** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
184186
@@ -194,7 +196,7 @@ Append all children of the given object to an array.
194196#### symbolTree.ancestorsToArray(object, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
195197Append all inclusive ancestors of the given object to an array.
196198
197- ` O(n) `
199+ ` O(n) ` where n is the amount of ancestors of the given ` object `
198200
199201** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
200202
@@ -210,7 +212,7 @@ Append all inclusive ancestors of the given object to an array.
210212#### symbolTree.treeToArray(root, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
211213Append all descendants of the given object to an array (in tree order).
212214
213- ` O(n) `
215+ ` O(n) ` where n is the amount of objects in the sub-tree of the given ` object `
214216
215217** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
216218
@@ -280,8 +282,9 @@ Iterate over all inclusive ancestors of the given object
280282#### symbolTree.treeIterator(root, options) ⇒ <code >Object</code >
281283Iterate over all descendants of the given object (in tree order).
282284
283- ` O(n) ` for the entire iteration<br >
284- ` O(n) ` for a single iteration (worst case)
285+ where n is the amount of objects in the sub-tree of the given ` root ` :
286+ ` O(n) ` (worst case for a single iterator)
287+ ` O(n) ` (amortized, when completing the iterator)<br >
285288
286289** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
287290** Returns** : <code >Object</code > - An iterable iterator (ES6)
@@ -296,8 +299,8 @@ Iterate over all descendants of the given object (in tree order).
296299#### symbolTree.index(child) ⇒ <code >Number</code >
297300Find the index of the given object (the number of preceding siblings).
298301
299- ` O(n) ` <br >
300- ` O(1) ` (cached )
302+ ` O(n) ` where n is the amount of preceding siblings <br >
303+ ` O(1) ` (amortized, if the tree is not modified )
301304
302305** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
303306** Returns** : <code >Number</code > - The number of preceding siblings, or -1 if the object has no parent
@@ -310,8 +313,8 @@ Find the index of the given object (the number of preceding siblings).
310313#### symbolTree.childrenCount(parent) ⇒ <code >Number</code >
311314Calculate the number of children.
312315
313- ` O(n) ` <br >
314- ` O(1) ` (cached )
316+ ` O(n) ` where n is the amount of children <br >
317+ ` O(1) ` (amortized, if the tree is not modified )
315318
316319** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
317320
@@ -334,7 +337,10 @@ Compare the position of an object relative to another object. A bit set is retur
334337The semantics are the same as compareDocumentPosition in DOM, with the exception that
335338DISCONNECTED never occurs with any other bit.
336339
337- ` O(n) ` (worst case)
340+ where n and m are the amount of ancestors of ` left ` and ` right ` ;
341+ where o is the amount of children of the lowest common ancestor of ` left ` and ` right ` :
342+ ` O(n + m + o) ` (worst case)
343+ `O(n + m) (amortized, if the tree is not modified)
338344
339345** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
340346
0 commit comments