@@ -133,7 +133,7 @@ Return the parent of the given object.
133
133
#### symbolTree.lastInclusiveDescendant(object) ⇒ <code >Object</code >
134
134
Find the inclusive descendant that is last in tree order of the given object.
135
135
136
- ` O(n) ` (worst case)
136
+ ` O(n) ` (worst case) where n is the depth of the subtree of ` object `
137
137
138
138
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
139
139
@@ -147,7 +147,8 @@ Find the preceding object (A) of the given object (B).
147
147
An object A is preceding an object B if A and B are in the same tree
148
148
and A comes before B in tree order.
149
149
150
- ` O(n) ` (worst case)
150
+ ` O(n) ` (worst case) <br >
151
+ ` O(1) ` (amortized when walking the entire tree)
151
152
152
153
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
153
154
@@ -163,7 +164,8 @@ Find the following object (A) of the given object (B).
163
164
An object A is following an object B if A and B are in the same tree
164
165
and A comes after B in tree order.
165
166
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)
167
169
168
170
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
169
171
@@ -178,7 +180,7 @@ and A comes after B in tree order.
178
180
#### symbolTree.childrenToArray(parent, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
179
181
Append all children of the given object to an array.
180
182
181
- ` O(n) `
183
+ ` O(n) ` where n is the amount of children of the given ` parent `
182
184
183
185
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
184
186
@@ -194,7 +196,7 @@ Append all children of the given object to an array.
194
196
#### symbolTree.ancestorsToArray(object, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
195
197
Append all inclusive ancestors of the given object to an array.
196
198
197
- ` O(n) `
199
+ ` O(n) ` where n is the amount of ancestors of the given ` object `
198
200
199
201
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
200
202
@@ -210,7 +212,7 @@ Append all inclusive ancestors of the given object to an array.
210
212
#### symbolTree.treeToArray(root, [ options] ) ⇒ <code >Array.< ; Object> ; </code >
211
213
Append all descendants of the given object to an array (in tree order).
212
214
213
- ` O(n) `
215
+ ` O(n) ` where n is the amount of objects in the sub-tree of the given ` object `
214
216
215
217
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
216
218
@@ -280,8 +282,9 @@ Iterate over all inclusive ancestors of the given object
280
282
#### symbolTree.treeIterator(root, options) ⇒ <code >Object</code >
281
283
Iterate over all descendants of the given object (in tree order).
282
284
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 >
285
288
286
289
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
287
290
** Returns** : <code >Object</code > - An iterable iterator (ES6)
@@ -296,8 +299,8 @@ Iterate over all descendants of the given object (in tree order).
296
299
#### symbolTree.index(child) ⇒ <code >Number</code >
297
300
Find the index of the given object (the number of preceding siblings).
298
301
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 )
301
304
302
305
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
303
306
** 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).
310
313
#### symbolTree.childrenCount(parent) ⇒ <code >Number</code >
311
314
Calculate the number of children.
312
315
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 )
315
318
316
319
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
317
320
@@ -334,7 +337,10 @@ Compare the position of an object relative to another object. A bit set is retur
334
337
The semantics are the same as compareDocumentPosition in DOM, with the exception that
335
338
DISCONNECTED never occurs with any other bit.
336
339
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)
338
344
339
345
** Kind** : instance method of <code >[ SymbolTree] ( #exp_module_symbol-tree--SymbolTree ) </code >
340
346
0 commit comments