Class: Trie

Trie()

Trie Class

Constructor

new Trie()

Source:

Members

size

Returns number of elements
Source:

Methods

add(val, contentopt) → {boolean}

Adds a new element to the Trie
Parameters:
Name Type Attributes Default Description
val any The value of the element
content any <optional>
null Content of the element, default null
Source:
Returns:
true if element was created, false if element exists
Type
boolean

clear()

Clears the Trie
Source:

contains(val) → {boolean}

Indicates if an element exists in the Trie
Parameters:
Name Type Description
val any The value of the element
Source:
Returns:
true if element exists, false if element does not exists
Type
boolean

find(prefix) → {Element}

Returns a sub Trie given a prefix
Parameters:
Name Type Description
prefix any The prefix of the element(s) to be found
Source:
Returns:
- Return Element matching the prefix
Type
Element

get(val) → {any}

Returns content of an element
Parameters:
Name Type Description
val any The value of the element
Source:
Returns:
- Content of the element, return null if element does not exists or if its content is not set
Type
any

remove(val) → {boolean}

Removes an element from the Trie
Parameters:
Name Type Description
val any The value of the element
Source:
Returns:
true if element exists, false if element does not exists
Type
boolean

toArray() → {Array}

Converts and return an array of elements contained in the Trie
Source:
Returns:
Type
Array

update(val, contentopt) → {boolean}

Updates the content of an existing element
Parameters:
Name Type Attributes Default Description
val any The value of the element
content any <optional>
null Content of the element, default null
Source:
Returns:
true if element was updated, false if element does not exists
Type
boolean