Package me.legrange.tree
Interface Tree<T>
-
- Type Parameters:
T- The type of data contained in the tree
- All Known Implementing Classes:
BinarySearchTree,BinaryTree,GeneralTree
public interface Tree<T>A tree for organising data.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Stream<T>breadthStream()Return a stream that does breadth-first traversal of the tree.booleancontains(T object)Check if the tree contains the given data somewhere.Stream<T>depthStream()Return a stream that does depth-first traversal of the tree.intgetDepth()Return the depth of the tree.Optional<T>getParent(T child)Get the parent data for child dataTgetRoot()Return the data at the root of the treeintgetWidth()Return the width of the tree
-
-
-
Method Detail
-
contains
boolean contains(T object)
Check if the tree contains the given data somewhere.- Parameters:
object- The object- Returns:
- Is it in the tree?
-
depthStream
Stream<T> depthStream()
Return a stream that does depth-first traversal of the tree.- Returns:
- The stream
-
breadthStream
Stream<T> breadthStream()
Return a stream that does breadth-first traversal of the tree.- Returns:
- The stream
-
getRoot
T getRoot()
Return the data at the root of the tree- Returns:
- The data
-
getDepth
int getDepth()
Return the depth of the tree.- Returns:
- The depth
-
getWidth
int getWidth()
Return the width of the tree- Returns:
-
-