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

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

Go to download

Everything needed to run a comprehensive dev environment. Just type X_ and pick a service from autocomplete; new dev modules will be added as they are built. The only dev service not included in the uber jar is xapi-dev-maven, as it includes all runtime dependencies of maven, adding ~4 seconds to build time, and 6 megabytes to the final output jar size (without xapi-dev-maven, it's ~1MB).

The 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 CollectionProxy
{

  static interface Many  extends IntTo> {
    void add(int key, T item);
  }

  static class IntToIterable  implements Iterable  {
    private final IntTo self;
    public IntToIterable(IntTo self) {
      this.self = self;
    }
    @Override
    public Iterator iterator() {
      return new IntToIterator(self);
    }
  }
  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--;
      }
    }
  }

  Iterable forEach();

  boolean add(T item);

  boolean addAll(Iterable items);

  @SuppressWarnings("unchecked")
  boolean addAll(T ... items);

  boolean insert(int pos, 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