APL/DEV 3.2/TP08/Tri/SearchTree.java
2023-03-07 16:14:57 +01:00

24 lines
501 B
Java

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();
}
}