Class TrieNode

  • All Implemented Interfaces:
    java.lang.Comparable

    public class TrieNode
    extends java.lang.Object
    implements java.lang.Comparable
    Class that implement a bucked for the nodes that are pointed by a Trie. Each node has a pair and a child Trie where its children appear. Copyright Antonio Gomariz PeƱalver 2013 This file is part of the SPMF DATA MINING SOFTWARE (http://www.philippe-fournier-viger.com/spmf). SPMF is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SPMF is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SPMF. If not, see .
    Author:
    agomariz
    • Constructor Summary

      Constructors 
      Constructor Description
      TrieNode​(ItemAbstractionPair pair)
      Creation of a TrieNode by means of only the pair component
      TrieNode​(ItemAbstractionPair pair, Trie child)
      Creation of a TrieNode by means of both pair and Trie components
      TrieNode​(ItemAbstractionPair pair, Trie child, boolean alreadyExplored)
      Creation of a TrieNode by means of both pair and Trie components and indicating if the node has already been traversed
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      It removes all the descendants tries appearing below this NodeTrie
      int compareTo​(java.lang.Object o)
      It compares the TrieNode with either another TrieNode, a ItemAbstractionPair object or an item.
      Trie getChild()
      It gets the Trie kept in the TrieNode
      ItemAbstractionPair getPair()
      It gets the ItemAbstractionPair object kept in the TrieNode
      boolean isAlreadyExplored()
      It answers to the question if the nodeTrie has already been traversed
      void setAlreadyExplored​(boolean alreadyExplored)
      It updates the flag that indicates if the NodeTrie has already been traversed
      void setChild​(Trie child)
      It updates the Trie component of the TrieNode by the Trie given as parameter
      void setPair​(ItemAbstractionPair child)
      It updates the ItemAbstractionPair component of the TrieNode by the pair given as parameter
      java.lang.String toString()
      Get the string representation of this trie node.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • TrieNode

        public TrieNode​(ItemAbstractionPair pair)
        Creation of a TrieNode by means of only the pair component
        Parameters:
        pair - ItemAbstractionPair to insert in the node
      • TrieNode

        public TrieNode​(ItemAbstractionPair pair,
                        Trie child)
        Creation of a TrieNode by means of both pair and Trie components
        Parameters:
        pair - ItemAbstractionPair to insert in the node
        child - Trie to insert in the node
      • TrieNode

        public TrieNode​(ItemAbstractionPair pair,
                        Trie child,
                        boolean alreadyExplored)
        Creation of a TrieNode by means of both pair and Trie components and indicating if the node has already been traversed
        Parameters:
        pair - ItemAbstractionPair to insert in the node
        child - Trie to insert in the node
        alreadyExplored -
    • Method Detail

      • getChild

        public Trie getChild()
        It gets the Trie kept in the TrieNode
        Returns:
        the trie
      • setChild

        public void setChild​(Trie child)
        It updates the Trie component of the TrieNode by the Trie given as parameter
        Parameters:
        child - Trie to insert in the node
      • getPair

        public ItemAbstractionPair getPair()
        It gets the ItemAbstractionPair object kept in the TrieNode
        Returns:
        the pair
      • setPair

        public void setPair​(ItemAbstractionPair child)
        It updates the ItemAbstractionPair component of the TrieNode by the pair given as parameter
        Parameters:
        child - Trie to insert in the node
      • clear

        public void clear()
        It removes all the descendants tries appearing below this NodeTrie
      • compareTo

        public int compareTo​(java.lang.Object o)
        It compares the TrieNode with either another TrieNode, a ItemAbstractionPair object or an item. They are compared by their pair components
        Specified by:
        compareTo in interface java.lang.Comparable
        Parameters:
        o - the other object
        Returns:
        0 if equals, -1 if smaller, otherwise 1
      • isAlreadyExplored

        public boolean isAlreadyExplored()
        It answers to the question if the nodeTrie has already been traversed
        Returns:
        true if it has been already explored
      • setAlreadyExplored

        public void setAlreadyExplored​(boolean alreadyExplored)
        It updates the flag that indicates if the NodeTrie has already been traversed
        Parameters:
        alreadyExplored -
      • toString

        public java.lang.String toString()
        Get the string representation of this trie node.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation