package myBtree; import java.util.function.Consumer; import java.util.Optional; import myBtree.Btree; import myBtree.Empty; final public class BtreeWrapper> { private Btree bt = null; static public> BtreeWrapper CreateEmpty() { return new BtreeWrapper(); } private BtreeWrapper() { this.bt = new Empty(); } private BtreeWrapper(Btree other) { this.bt = other; } public BtreeWrapper getBtreeWrapper() { return new BtreeWrapper(this.bt); } public void display(Consumer func) { this.bt.display(func); } public BtreeWrapper add(T data) { this.bt = this.bt.add(data); return this; } public Optional> find(T data) { var ans = this.bt.find(data); if (ans.isEmpty()) { return Optional.empty(); }else { return Optional.of(new BtreeWrapper(ans.get())); } } public boolean isEmpty() { return this.bt.isEmpty(); } public BtreeWrapper remove(T data) { this.bt = this.bt.remove(data); return this; } }