case class Trie(valid: Boolean = false, children: Map[String, Trie] = Map()) extends Product with Serializable
- Alphabetic
- By Inheritance
- Trie
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def add(word: String, trie: Trie = this): Trie
Add a word to a Trie.
Add a word to a Trie.
- word
- The word to add to the Trie.
- trie
- The Trie where the word is being added.
- returns
A Trie with the additional word added.
- def addMany(words: Seq[String], trie: Trie = this): Trie
Add multiple words to a given Trie.
Add multiple words to a given Trie.
- words
- Sequence of words to add to the Trie.
- trie
- The Trie where the words will be added.
- returns
A Trie with the additional words added.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- val children: Map[String, Trie]
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def getSuffixes(trie: Trie = this): Seq[String]
DFS from a given Trie node to create a list of all suffixes that form valid words.
DFS from a given Trie node to create a list of all suffixes that form valid words. Running this function from the root node of a Trie will yield all valid words in that Trie.
- trie
- The current node to find all suffixes.
- returns
List of all suffixes that form valid words for a given Trie.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def remove(word: String, trie: Trie = this): (Boolean, Trie)
Remove a given word from a Trie.
Remove a given word from a Trie. If the word does not exist in the Trie, return the original Trie.
- word
- The word to be removed from the Trie.
- trie
- The Trie from which the word will be deleted.
- returns
Boolean and Trie pair. If the boolean is false, the word does not exist in the Trie. If the boolean is true, the word was removed from the Trie.
- def removeMany(words: Seq[String], trie: Trie = this): (Seq[String], Trie)
Remove multiple words from a Trie.
Remove multiple words from a Trie. Return the updated Trie with words removed, along with a list of words that did not exist in the Trie.
- words
- List of words to be removed from the Trie.
- trie
- The Trie where words will be removed.
- returns
List of words that were not removed from the Trie, and the updated Trie.
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def traverse(prefix: String, trie: Trie = this): Option[Trie]
Traverse a string, returning the Trie node of the last character in the string, if it exists in the Trie.
Traverse a string, returning the Trie node of the last character in the string, if it exists in the Trie.
- prefix
- The string to traverse.
- trie
- The current node to search.
- returns
The Trie node of the last character in the string, if it exists.
- val valid: Boolean
- def validPrefix(prefix: String, trie: Trie = this): Boolean
Traverse a string, returning false if the string does not exist in the Trie.
Traverse a string, returning false if the string does not exist in the Trie.
- prefix
- The string to traverse.
- trie
- The current node to begin the prefix search.
- returns
True if the prefix exists in the Trie, false otherwise.
- def validWord(prefix: String, trie: Trie = this): Boolean
Traverse a string, returning false if the string is not a valid word in the Trie.
Traverse a string, returning false if the string is not a valid word in the Trie.
- prefix
- The string to traverse.
- trie
- The current node to begin the search.
- returns
True if the prefix is a valid word, false otherwise.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated