goog.structs.Trie |
opt_trie
: goog.structs.Trie.<VALUE> | Object.<string, VALUE>>
Optional
goog.structs.Trie or Object to initialize trie with.
|
![]()
Adds the given key/value pair in the trie. Throw an exception if the key
already exists in the trie. O(L), where L is the length of the key.
Arguments:
|
code » | ||||
![]()
Completely empties a trie of all keys and values. ~O(1)
|
code » | ||||
Clones a trie and returns a new trie. O(N), where N is the number of nodes
in the trie.
|
code » | ||||
Checks to see if a certain key is in the trie. O(L), where L is the length
of the key.
|
code » | ||||
Checks to see if a certain prefix is in the trie. O(L), where L is the length
of the prefix.
|
code » | ||||
Checks to see if a certain value is in the trie. Worst case is O(N) where
N is the number of nodes in the trie.
Arguments:
Returns: boolean
Whether the trie contains the value.
|
code » | ||||
![]()
Retrieves a value from the trie given a key. O(L), where L is the length of
the key.
Arguments:
Returns: VALUE | undefined
The value of the key in the trie, or undefined if
the trie does not contain this key.
|
code » | ||||
Traverse along the given path, returns the child node at ending.
Returns undefined if node for the path doesn't exist.
Arguments:
|
code » | ||||
Returns the number of key value pairs in the trie. O(N), where N is the
number of nodes in the trie.
TODO: This could be optimized by storing a weight (count below) in every
node.
Returns: number
The number of pairs.
|
code » | ||||
Retrieves all values from the trie that correspond to prefixes of the given
input key. O(L), where L is the length of the key.
Arguments:
|
code » | ||||
Gets the keys of the trie. Not returned in any reliable order. O(N) where
N is the number of nodes in the trie (or prefix subtree).
|
code » | ||||
![]()
Private method to get keys from the trie. Builds the keys as it goes.
|
code » | ||||
Gets the values of the trie. Not returned in any reliable order. O(N) where
N is the number of nodes in the trie. Calls getValuesInternal_.
|
code » | ||||
![]()
Gets the values of the trie. Not returned in any reliable order. O(N) where
N is the number of nodes in the trie. Builds the values as it goes.
Arguments:
|
code » | ||||
Returns true if this trie contains no elements. ~O(1).
Returns: boolean
True iff this trie contains no elements.
|
code » | ||||
![]()
Removes a key from the trie or throws an exception if the key is not in the
trie. O(L), where L is the length of the key.
Arguments:
Returns: !VALUE
The value whose key was removed.
|
code » | ||||
![]()
Sets the given key/value pair in the trie. O(L), where L is the length
of the key.
Arguments:
|
code » | ||||
![]()
Adds multiple key/value pairs from another goog.structs.Trie or Object.
O(N) where N is the number of nodes in the trie.
Arguments:
|
code » | ||||
![]()
Helper function for set and add. Adds the given key/value pair to
the trie, or, if the key already exists, sets the value of the key. If
opt_add is true, then throws an exception if the key already has a value in
the trie. O(L), where L is the length of the key.
Arguments:
|
code » |