Class ListedHashTree
-
- All Implemented Interfaces:
-
java.io.Serializable,java.lang.Cloneable,java.util.Map
public class ListedHashTree extends HashTree implements Serializable, Cloneable
ListedHashTree is a different implementation of the HashTree collection class. In the ListedHashTree, the order in which values are added is preserved . Any listing of nodes or iteration through the list of nodes of a ListedHashTree will be given in the order in which the nodes were added to the tree.
-
-
Constructor Summary
Constructors Constructor Description ListedHashTree()ListedHashTree(Object key)ListedHashTree(Collection<out Object> keys)ListedHashTree(Array<Object> keys)
-
Method Summary
Modifier and Type Method Description Objectclone()Create a clone of this HashTree. ListedHashTreegetTree(Object key)Gets the HashTree mapped to the given key. voidset(Object key, Object value)Sets a key and it's value in the HashTree. voidset(Object key, HashTree t)Sets a key into the current tree and assigns it a HashTree as its subtree. voidset(Object key, Array<Object> values)Sets a key and its values in the HashTree. voidset(Object key, Collection<out Object> values)Sets a key and its values in the HashTree. voidreplaceKey(Object currentKey, Object newKey)Finds the given current key, and replaces it with the given new key. ListedHashTreecreateNewTree()Creates a new tree. ListedHashTreecreateNewTree(Object key)Creates a new tree. ListedHashTreecreateNewTree(Collection<out Object> values)Creates a new tree. ListedHashTreeadd(Object key)Adds an key into the HashTree at the current level. Collection<Object>list()Gets a Collection of all keys in the current HashTree node. HashTreeremove(Object key)Removes the entire branch specified by the given key. Array<Object>getArray()Gets an array of all keys in the current HashTree node. inthashCode()Returns a hashcode for this HashTree. booleanequals(Object o)Compares all objects in the tree and verifies that the two trees contain the same objects at the same tree levels. voidclear()Clears the HashTree of all contents. -
Methods inherited from class org.apache.jorphan.collections.HashTree
add, add, add, add, add, add, add, add, add, add, add, add, add, containsKey, containsValue, entrySet, get, getArray, getArray, getArray, getTree, getTree, isEmpty, keySet, list, list, list, put, putAll, search, set, set, set, set, set, size, toString, traverse, values -
Methods inherited from class java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, copyOf, entry, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, of, ofEntries, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ListedHashTree
ListedHashTree()
-
ListedHashTree
ListedHashTree(Object key)
-
ListedHashTree
ListedHashTree(Collection<out Object> keys)
-
-
Method Detail
-
clone
Object clone()
Create a clone of this HashTree. This is not a deep clone (i.e., the contents of the tree are not cloned).
-
getTree
ListedHashTree getTree(Object key)
Gets the HashTree mapped to the given key.
- Parameters:
key- Key used to find appropriate HashTree()- Returns:
the HashTree for
key
-
set
void set(Object key, Object value)
Sets a key and it's value in the HashTree. It actually sets up a key, and then creates a node for the key and sets the value to the new node, as a key. Any previous nodes that existed under the given key are lost.
-
set
void set(Object key, HashTree t)
Sets a key into the current tree and assigns it a HashTree as its subtree. Any previous entries under the given key are removed.
-
set
void set(Object key, Array<Object> values)
Sets a key and its values in the HashTree. It sets up a key in the current node, and then creates a node for that key, and sets all the values in the array as keys in the new node. Any keys previously held under the given key are lost.
-
set
void set(Object key, Collection<out Object> values)
Sets a key and its values in the HashTree. It sets up a key in the current node, and then creates a node for that key, and set all the values in the array as keys in the new node. Any keys previously held under the given key are removed.
-
replaceKey
void replaceKey(Object currentKey, Object newKey)
Finds the given current key, and replaces it with the given new key. Any tree structure found under the original key is moved to the new key.
-
createNewTree
ListedHashTree createNewTree()
Creates a new tree. This method exists to allow inheriting classes to generate the appropriate types of nodes. For instance, when a node is added, it's value is a HashTree. Rather than directly calling the HashTree() constructor, the createNewTree() method is called. Inheriting classes should override these methods and create the appropriate subclass of HashTree.
-
createNewTree
ListedHashTree createNewTree(Object key)
Creates a new tree. This method exists to allow inheriting classes to generate the appropriate types of nodes. For instance, when a node is added, it's value is a HashTree. Rather than directly calling the HashTree() constructor, the createNewTree() method is called. Inheriting classes should override these methods and create the appropriate subclass of HashTree.
-
createNewTree
ListedHashTree createNewTree(Collection<out Object> values)
Creates a new tree. This method exists to allow inheriting classes to generate the appropriate types of nodes. For instance, when a node is added, it's value is a HashTree. Rather than directly calling the HashTree() constructor, the createNewTree() method is called. Inheriting classes should override these methods and create the appropriate subclass of HashTree.
-
add
ListedHashTree add(Object key)
Adds an key into the HashTree at the current level. If a HashTree exists for the key already, no new tree will be added
-
list
Collection<Object> list()
Gets a Collection of all keys in the current HashTree node. If the HashTree represented a file system, this would be like getting a collection of all the files in the current folder.
-
getArray
Array<Object> getArray()
Gets an array of all keys in the current HashTree node. If the HashTree represented a file system, this would be like getting an array of all the files in the current folder.
-
hashCode
int hashCode()
Returns a hashcode for this HashTree.
-
equals
boolean equals(Object o)
Compares all objects in the tree and verifies that the two trees contain the same objects at the same tree levels. Returns true if they do, false otherwise.
-
clear
void clear()
Clears the HashTree of all contents.
-
-
-
-