程序包 weka.core

类 Trie

java.lang.Object
weka.core.Trie
所有已实现的接口:
Serializable, Cloneable, Iterable<String>, Collection<String>, RevisionHandler

public class Trie extends Object implements Serializable, Cloneable, Collection<String>, RevisionHandler
A class representing a Trie data structure for strings. See also Trie on WikiPedia.
版本:
$Revision: 1.2 $
作者:
fracpete (fracpete at waikato dot ac dot nz)
另请参阅:
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static class 
    Represents an iterator over a trie
    static class 
    Represents a node in the trie.
  • 构造器概要

    构造器
    构造器
    说明
    initializes the data structure
  • 方法概要

    修饰符和类型
    方法
    说明
    boolean
    Ensures that this collection contains the specified element.
    boolean
    addAll(Collection<? extends String> c)
    Adds all of the elements in the specified collection to this collection
    void
    Removes all of the elements from this collection
    returns a deep copy of itself
    boolean
    Returns true if this collection contains the specified element.
    boolean
    Returns true if this collection contains all of the elements in the specified collection.
    boolean
    checks whether the given prefix is stored in the trie
    boolean
    Compares the specified object with this collection for equality.
    returns the common prefix for all the nodes
    Returns the revision string.
    returns the root node of the trie
    returns all stored strings that match the given prefix
    int
    Returns the hash code value for this collection.
    boolean
    Returns true if this collection contains no elements.
    Returns an iterator over the elements in this collection.
    static void
    main(String[] args)
    Only for testing (prints the built Trie).
    boolean
    Removes a single instance of the specified element from this collection, if it is present.
    boolean
    Removes all this collection's elements that are also contained in the specified collection
    boolean
    Retains only the elements in this collection that are contained in the specified collection
    int
    Returns the number of elements in this collection.
    Returns an array containing all of the elements in this collection.
    <T> T[]
    toArray(T[] a)
    Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
    returns the trie in string representation

    从类继承的方法 java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    从接口继承的方法 java.util.Collection

    parallelStream, removeIf, spliterator, stream, toArray

    从接口继承的方法 java.lang.Iterable

    forEach
  • 构造器详细资料

    • Trie

      public Trie()
      initializes the data structure
  • 方法详细资料

    • add

      public boolean add(String o)
      Ensures that this collection contains the specified element.
      指定者:
      add 在接口中 Collection<String>
      参数:
      o - the string to add
      返回:
      true if the structure changed
    • addAll

      public boolean addAll(Collection<? extends String> c)
      Adds all of the elements in the specified collection to this collection
      指定者:
      addAll 在接口中 Collection<String>
      参数:
      c - the collection to add
    • clear

      public void clear()
      Removes all of the elements from this collection
      指定者:
      clear 在接口中 Collection<String>
    • clone

      public Object clone()
      returns a deep copy of itself
      返回:
      a copy of itself
    • contains

      public boolean contains(Object o)
      Returns true if this collection contains the specified element.
      指定者:
      contains 在接口中 Collection<String>
      参数:
      o - the object to check for in trie
      返回:
      true if found
    • containsAll

      public boolean containsAll(Collection<?> c)
      Returns true if this collection contains all of the elements in the specified collection.
      指定者:
      containsAll 在接口中 Collection<String>
      参数:
      c - the collection to look for in the trie
      返回:
      true if all elements were found
    • containsPrefix

      public boolean containsPrefix(String prefix)
      checks whether the given prefix is stored in the trie
      参数:
      prefix - the prefix to check
      返回:
      true if the prefix is part of the trie
    • equals

      public boolean equals(Object o)
      Compares the specified object with this collection for equality.
      指定者:
      equals 在接口中 Collection<String>
      覆盖:
      equals 在类中 Object
      参数:
      o - the object to check for equality
    • getCommonPrefix

      public String getCommonPrefix()
      returns the common prefix for all the nodes
      返回:
      the result of the search
    • getRoot

      public Trie.TrieNode getRoot()
      returns the root node of the trie
      返回:
      the root node
    • getWithPrefix

      public Vector<String> getWithPrefix(String prefix)
      returns all stored strings that match the given prefix
      参数:
      prefix - the prefix that all strings must have
      返回:
      all strings that match the prefix
    • hashCode

      public int hashCode()
      Returns the hash code value for this collection.
      指定者:
      hashCode 在接口中 Collection<String>
      覆盖:
      hashCode 在类中 Object
      返回:
      the hash code
    • isEmpty

      public boolean isEmpty()
      Returns true if this collection contains no elements.
      指定者:
      isEmpty 在接口中 Collection<String>
      返回:
      true if empty
    • iterator

      public Iterator<String> iterator()
      Returns an iterator over the elements in this collection.
      指定者:
      iterator 在接口中 Collection<String>
      指定者:
      iterator 在接口中 Iterable<String>
      返回:
      returns an iterator over all the stored strings
    • remove

      public boolean remove(Object o)
      Removes a single instance of the specified element from this collection, if it is present.
      指定者:
      remove 在接口中 Collection<String>
      参数:
      o - the object to remove
      返回:
      true if this collection changed as a result of the call
    • removeAll

      public boolean removeAll(Collection<?> c)
      Removes all this collection's elements that are also contained in the specified collection
      指定者:
      removeAll 在接口中 Collection<String>
      参数:
      c - the collection to remove
      返回:
      true if the collection changed
    • retainAll

      public boolean retainAll(Collection<?> c)
      Retains only the elements in this collection that are contained in the specified collection
      指定者:
      retainAll 在接口中 Collection<String>
      参数:
      c - the collection to use as reference
      返回:
      true if this collection changed as a result of the call
    • size

      public int size()
      Returns the number of elements in this collection.
      指定者:
      size 在接口中 Collection<String>
      返回:
      the number of nodes in the tree
    • toArray

      public Object[] toArray()
      Returns an array containing all of the elements in this collection.
      指定者:
      toArray 在接口中 Collection<String>
      返回:
      the stored strings as array
    • toArray

      public <T> T[] toArray(T[] a)
      Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array.
      指定者:
      toArray 在接口中 Collection<String>
      参数:
      a - the array into which the elements of this collection are to be stored
      返回:
      an array containing the elements of this collection
    • toString

      public String toString()
      returns the trie in string representation
      覆盖:
      toString 在类中 Object
      返回:
      the trie as string
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      返回:
      the revision
    • main

      public static void main(String[] args)
      Only for testing (prints the built Trie). Arguments are added to the Trie. If not arguments provided then a few default strings are uses for building.
      参数:
      args - commandline arguments