Advertisement
saltycracker

Empty.java

Sep 28th, 2020 (edited)
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. package myBtree;
  2.  
  3. import java.util.function.Consumer;
  4. import java.util.Optional;
  5.  
  6. final public class Empty<T extends Comparable<T>> extends Btree<T> {
  7.    
  8.   public Empty() {}
  9.  
  10.   @Override
  11.   public void display(Consumer<T> func) {}
  12.  
  13.   @Override
  14.   public Btree<T> add(T data) {
  15.     return new Node<T>(data, this, this);
  16.   }
  17.  
  18.   @Override
  19.   public Optional<Btree<T>> find(T data) {
  20.     return Optional.empty();
  21.   }
  22.  
  23.   @Override
  24.   public boolean isEmpty() {
  25.     return true;
  26.   }
  27.  
  28.   @Override
  29.   public Btree<T> remove(T data) {
  30.     return this;
  31.   }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement