All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xapi.collect.api.IntTo Maven / Gradle / Ivy

There is a newer version: 0.5
Show newest version
package xapi.collect.api;

import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import xapi.collect.proxy.CollectionProxy;


public interface IntTo 
extends Iterable, CollectionProxy
{

  static interface Many  extends IntTo> {
  }

  static class IntToIterator  implements Iterator  {
    private IntTo source;
    int pos = 0;
    public IntToIterator(IntTo source) {
      this.source = source;
    }
    @Override
    public boolean hasNext() {
      return pos < source.size();
    }
    @Override
    public T next() {
      return source.at(pos++);
    }
    @Override
    public void remove() {
      if (source.remove(pos-1)) {
        pos--;
      }
    }
  }

  boolean add(T item);

  boolean contains(T value);

  T at(int index);

  int indexOf(T value);

  boolean remove(int index);

  boolean findRemove(T value, boolean all);

  void set(int index, T value);

  void push(T value);

  T pop();

  /**
   * If this IntTo is mutable,
   * you will be getting a ListProxy, backed by this IntTo.
   * If the underlying IntTo forbids duplicates,
   * the ListProxy will act like a set.
   * 

* If this IntTo is immutable, * you are getting an ArrayList you can mutate as you wish. */ List asList(); /** * If this IntTo is mutable, * you will be getting a SetProxy, backed by this IntTo. * * This SetProxy will call remove(item) before every addInternal(item). * * If this IntTo is immutable, * you are getting a HashSet you can mutate as you wish. */ Set asSet(); /** * If this IntTo is mutable, * you will be getting a DequeProxy, backed by this IntTo. * * If the underlying IntTo forbids duplicates, * the DequeProxy will act like a set. * * If this IntTo is immutable, * you are getting a LinkedList you can mutate as you wish. */ Deque asDeque(); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy