Exemplo n.º 1
0
 protected Node erase(K key) {
   int value = compare(key, this.key);
   if (value == 0) return merge(left, right);
   if (value < 0) {
     left = left.erase(key);
     updateSize();
     return this;
   }
   right = right.erase(key);
   updateSize();
   return this;
 }
Exemplo n.º 2
0
 public K pollFirst() {
   K first = first();
   if (first == null) throw new NoSuchElementException();
   root.erase(first);
   return first;
 }
Exemplo n.º 3
0
 public boolean remove(Object o) {
   if (!contains(o)) return false;
   //noinspection unchecked
   root = root.erase((K) o);
   return true;
 }
Exemplo n.º 4
0
 public K pollLast() {
   K last = last();
   if (last == null) throw new NoSuchElementException();
   root.erase(last);
   return last;
 }