Class PathTrie


  • public class PathTrie
    extends java.lang.Object
    a class that implements prefix matching for components of a filesystem path. the trie looks like a tree with edges mapping to the component of a path. example /ab/bc/cf would map to a trie / ab/ (ab) bc/ / (bc) cf/ (cf)
    • Constructor Summary

      Constructors 
      Constructor Description
      PathTrie()
      construct a new PathTrie with a root node of /
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPath​(java.lang.String path)
      add a path to the path trie
      void clear()
      clear all nodes
      void deletePath​(java.lang.String path)
      delete a path from the trie
      java.lang.String findMaxPrefix​(java.lang.String path)
      return the largest prefix for the input path.
      • Methods inherited from class java.lang.Object

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

      • PathTrie

        public PathTrie()
        construct a new PathTrie with a root node of /
    • Method Detail

      • addPath

        public void addPath​(java.lang.String path)
        add a path to the path trie
        Parameters:
        path -
      • deletePath

        public void deletePath​(java.lang.String path)
        delete a path from the trie
        Parameters:
        path - the path to be deleted
      • findMaxPrefix

        public java.lang.String findMaxPrefix​(java.lang.String path)
        return the largest prefix for the input path.
        Parameters:
        path - the input path
        Returns:
        the largest prefix for the input path.
      • clear

        public void clear()
        clear all nodes