Пример #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;
 }