Exemplo n.º 1
0
 @Override
 public T selectAny() {
   Iterator<T> it = backend.iterator();
   if (it.hasNext()) {
     return it.next();
   } else {
     return null;
   }
 }
Exemplo n.º 2
0
  @Override
  public Collection<T> remove(Object element) {
    if (element == null) {
      return this;
    }

    Builder<T, ? extends Collection<T>> builder = createBuilder();
    Iterator<T> it = backend.iterator();
    while (it.hasNext()) {
      T e = it.next();
      if (element.equals(e)) {
        return builder.addAll(it).build();
      } else {
        builder.add(e);
      }
    }
    return this;
  }
Exemplo n.º 3
0
  @Override
  public Iterator<T> iterator() {
    Iterator<T> it = backend.iterator();
    return new Iterator<T>() {
      // Note: this implementation does not override (willingly) the
      // 'remove' method which (by default) throws an
      // UnsupportedOperationException.

      @Override
      public boolean hasNext() {
        return it.hasNext();
      }

      @Override
      public T next() {
        return it.next();
      }
    };
  }