-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing: finalize testInvalidateResults #188180
Conversation
Also sends the tests as a bulk to the renderer, and implements a prefix tree for doing invalidation checks (which I plan to adopt elsewhere later on, perhaps in debt week.)
insert(key: Iterable<string>, value: V): void { | ||
let node = this.root; | ||
for (const part of key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path
might be a better name.
insert(key: Iterable<string>, value: V): void { | |
let node = this.root; | |
for (const part of key) { | |
insert(path: Iterable<string>, value: V): void { | |
let node = this.root; | |
for (const part of path) { |
find(key: Iterable<string>): V | undefined { | ||
let node = this.root; | ||
for (const segment of key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find(key: Iterable<string>): V | undefined { | |
let node = this.root; | |
for (const segment of key) { | |
find(path: Iterable<string>): V | undefined { | |
let node = this.root; | |
for (const segment of path) { |
* A simple prefix tree implementation where a value is stored based on | ||
* well-defined prefix segments. | ||
*/ | ||
export class WellDefinedPrefixTree<V> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe RadixTrie
is a better name? https://en.wikipedia.org/wiki/Radix_tree
} | ||
|
||
/** Gets whether the tree has the key, or a parent of the key, already inserted. */ | ||
hasKeyOrParent(key: Iterable<string>): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
hasKeyOrParent(key: Iterable<string>): boolean { | |
containsPrefixOfPath(path: Iterable<string>): boolean { |
Might be easier to understand?
} | ||
|
||
/** Gets whether the tree has the given key or any children. */ | ||
hasKeyOrChildren(key: Iterable<string>): boolean { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
hasKeyOrChildren(key: Iterable<string>): boolean { | |
containsExtensionOfPath(path: Iterable<string>): boolean { |
?
(Assuming the empty extension is an extension)
tree.insert(key, 42); | ||
|
||
assert.strictEqual(tree.hasKeyOrParent(['foo', 'bar', 'baz']), true); | ||
assert.strictEqual(tree.hasKeyOrParent(['foo', 'bar']), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test for tree.hasKeyOrParent(['foo', 'baz'])
might be interesting
Left some comments, but feel free to ignore |
Also sends the tests as a bulk to the renderer, and implements a
prefix tree for doing invalidation checks (which I plan to adopt
elsewhere later on, perhaps in debt week.)