Package digilib.util

Class HashTree


  • public class HashTree
    extends Object
    Tree representation wrapper for a HashMap. The HashTree is constructed from a HashMap filled with 'branches' with 'leaves'. The branches are stored as String keys in the HashMap. The String values are leaves. Branches are matched in 'twigs' separated by 'twig separator' Strings. The return values for a match are leaf values separated by 'leaf separator' Strings.
    Author:
    casties
    • Constructor Detail

      • HashTree

        public HashTree​(Map<String,​String> t,
                        String twig_separator,
                        String leaf_separator)
        Constructor of a HashTree. Creates a HashTree wrapper around a given HashMap, using the given twig separator and leaf separator.
        Parameters:
        t - the Map
        twig_separator - the twig separator
        leaf_separator - the leaf separator
    • Method Detail

      • match

        public List<String> match​(String branch)
        Matches the given branch against the HashTree. Returns a LinkedList of all leaves on all matching branches in the tree. Branches in the tree match if they are substrings starting at the same root.
        Parameters:
        branch - the branch
        Returns:
        list of leaves