예제 #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;
 }
예제 #2
0
 public K pollFirst() {
   K first = first();
   if (first == null) throw new NoSuchElementException();
   root.erase(first);
   return first;
 }
예제 #3
0
 public boolean remove(Object o) {
   if (!contains(o)) return false;
   //noinspection unchecked
   root = root.erase((K) o);
   return true;
 }
예제 #4
0
 public K pollLast() {
   K last = last();
   if (last == null) throw new NoSuchElementException();
   root.erase(last);
   return last;
 }