APL/DEV 3.2/TP08/Tri/SearchTree.java

24 lines
501 B
Java
Raw Normal View History

2023-03-07 16:14:57 +01:00
public class SearchTree<T> {
private TreeNode<T> root;
private TreeComparator<T> comparator;
public SearchTree(TreeComparator<T> comparator) {
this.comparator = comparator;
}
public void add(T object) {
if (root != null) root.add(object);
else root = new TreeNode<T>(this, object);
}
public TreeComparator<T> getComparator() {
return comparator;
}
@Override
public String toString() {
return root.toString();
}
}