The caseSensitive function is a getter that returns the value of the protected _caseSensitive property.
The value of the _caseSensitive protected variable
The size function returns the size of the stack.
The number of elements in the list
The function returns the _toElementFn property, which is a function that converts a raw element to a specific type.
The function get toElementFn()
is returning either a function that takes a raw element
rawElement
of type R
and returns an element E
, or undefined
if no function is assigned to
_toElementFn
.
Protected
_caseProtected
_getTime Complexity: O(n) Space Complexity: O(1)
The function is an implementation of the Symbol.iterator method that returns an IterableIterator.
Rest
...args: any[]The args
parameter in the code snippet represents a rest parameter. It
allows the function to accept any number of arguments as an array. In this case, the args
parameter is used to pass any number of arguments to the _getIterator
method.
Time Complexity: O(l), where l is the length of the word being deleted. Space Complexity: O(n) - Due to the recursive DFS approach.
Remove a word from the Trie structure. @param{string} word - The word to delete.
True if the word was successfully removed.
Time Complexity: O(n) Space Complexity: O(1)
The every
function checks if every element in the array satisfies a given predicate.
The predicate
parameter is a callback function that takes three arguments:
the current element being processed, its index, and the array it belongs to. It should return a
boolean value indicating whether the element satisfies a certain condition or not.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as this
when executing the predicate
function. If thisArg
is provided, it will be
passed as the this
value to the predicate
function. If thisArg
is
The every
method is returning a boolean value. It returns true
if every element in
the array satisfies the provided predicate function, and false
otherwise.
Time Complexity: O(n) Space Complexity: O(n)
The filter
function takes a predicate function and returns a new array containing all the
elements for which the predicate function returns true.
The predicate
parameter is a callback function that takes three arguments:
word
, index
, and this
. It should return a boolean value indicating whether the current
element should be included in the filtered results or not.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that allows you to
specify the value of this
within the predicate
function. It is used when you want to bind a
specific object as the context for the predicate
function. If thisArg
is provided, it will be
The filter
method is returning an array of strings (string[]
).
Time Complexity: O(n) Space Complexity: O(1)
The find
function iterates over the elements of an array-like object and returns the first
element that satisfies the provided callback function.
The callbackfn parameter is a function that will be called for each element in the array. It takes three arguments: the current element being processed, the index of the current element, and the array itself. The function should return a boolean value indicating whether the current element matches the desired condition.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as this
when executing the callbackfn
function. If thisArg
is provided, it will
be passed as the this
value to the callbackfn
function. If thisArg @returns The
findmethod returns the first element in the array that satisfies the provided callback function. If no element satisfies the callback function,
undefined` is returned.
Time Complexity: O(n) Space Complexity: O(1)
The forEach
function iterates over each element in an array-like object and calls a callback
function for each element.
The callbackfn parameter is a function that will be called for each element in the array. It takes three arguments: the current element being processed, the index of the current element, and the array that forEach was called upon.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as this
when executing the callbackfn
function. If thisArg
is provided, it will
be passed as the this
value to the callbackfn
function. If `thisArg
Time Complexity: O(n), where n is the total number of nodes in the trie. Space Complexity: O(l), where l is the length of the longest common prefix.
Get the longest common prefix among all the words stored in the Trie.
The longest common prefix found in the Trie.
Time Complexity: O(w * l), where w is the number of words retrieved, and l is the average length of the words. Space Complexity: O(w * l) - The space required for the output array.
The getAll
function returns an array of all words in a Trie data structure that start with a given prefix.
The prefix
parameter is a string that represents the prefix that we want to search for in the
trie. It is an optional parameter, so if no prefix is provided, it will default to an empty string.
The max count of words will be found
If true, when the prefix provided as '', returns all the words in the trie.
an array of strings.
Time Complexity: O(n), where n is the total number of nodes in the trie. Space Complexity: O(l), where l is the length of the input prefix.
Check if the input string is a common prefix in the Trie, meaning it's a prefix shared by all words in the Trie.
The input string representing the common prefix to check for.
True if it's a common prefix in the Trie.
Time Complexity: O(l), where l is the length of the input prefix. Space Complexity: O(1) - Constant space.
Check if a given input string is a prefix of any existing word in the Trie, whether as an absolute prefix or a complete word.
The input string representing the prefix to check.
True if it's a prefix in the Trie.
Time Complexity: O(l), where l is the length of the input prefix. Space Complexity: O(1) - Constant space.
Check if a given input string has an absolute prefix in the Trie, meaning it's not a complete word.
The input string to check.
True if it's an absolute prefix in the Trie.
Time Complexity: O(n) Space Complexity: O(n)
The map
function creates a new Trie by applying a callback function to each element in the
current Trie.
The callback parameter is a function that will be called for each element in the Trie. It takes four arguments:
Optional
toElementFn: ((rawElement: RM) => string)The toElementFn
parameter is an optional function that can be used to
convert the raw element (RM
) into a string representation. This can be useful if the raw element
is not already a string or if you want to customize how the element is converted into a string. If
this parameter is
Optional
thisArg: anyThe thisArg
parameter is an optional argument that allows you to
specify the value of this
within the callback function. It is used to set the context or scope
in which the callback function will be executed. If thisArg
is provided, it will be used as the
value of
a new Trie object.
Time Complexity: O(n) Space Complexity: O(1)
The reduce
function iterates over the elements of an array-like object and applies a callback
function to reduce them into a single value.
The callbackfn parameter is a function that will be called for each element in the array. It takes four arguments:
The initialValue parameter is the initial value of the accumulator. It is the value that the accumulator starts with before the reduction operation begins.
The reduce
method is returning the final value of the accumulator after iterating over
all the elements in the array and applying the callback function to each element.
Time Complexity: O(n) Space Complexity: O(1)
The "some" function checks if at least one element in a collection satisfies a given predicate.
The predicate
parameter is a callback function that takes three arguments:
value
, index
, and array
. It should return a boolean value indicating whether the current
element satisfies the condition.
Optional
thisArg: anyThe thisArg
parameter is an optional argument that specifies the value
to be used as the this
value when executing the predicate
function. If thisArg
is provided,
it will be passed as the this
value to the predicate
function. If `thisArg
a boolean value. It returns true if the predicate function returns true for any element in the collection, and false otherwise.