package jetbrains.mps.baseLanguage.collections.trove.runtime;

/*Generated by MPS */

import java.util.AbstractList;
import java.util.List;
import java.io.Serializable;
import gnu.trove.TLongArrayList;
import java.util.ListIterator;
import java.util.Iterator;
import java.util.Collection;
import java.util.NoSuchElementException;

public class TLongArrayListDecorator extends AbstractList<Long> implements List<Long>, Serializable {
  private static final long serialVersionUID = -3396176387555572481L;
  private TLongArrayList primList;
  public TLongArrayListDecorator() {
  }
  public TLongArrayListDecorator(TLongArrayList prim) {
    this.primList = prim;
  }
  @Override
  protected void removeRange(int fromIdx, int toIdx) {
    this.primList.remove(fromIdx, toIdx - fromIdx);
  }
  @Override
  public int hashCode() {
    return super.hashCode();
  }
  @Override
  public boolean equals(Object that) {
    if (that instanceof TLongArrayListDecorator && this.primList == ((TLongArrayListDecorator) that).primList) {
      return true;
    }
    return super.equals(that);
  }
  @Override
  public List<Long> subList(int fromIdx, int toIdx) {
    return new TLongArrayListDecorator(this.primList.subList(fromIdx, toIdx));
  }
  @Override
  public ListIterator<Long> listIterator() {
    return new TLongListIterator(0);
  }
  @Override
  public void clear() {
    this.primList.clear();
  }
  @Override
  public int lastIndexOf(Object e) {
    return this.primList.lastIndexOf(this.unwrap(e));
  }
  @Override
  public int indexOf(Object e) {
    return this.primList.indexOf(this.unwrap(e));
  }
  @Override
  public boolean add(Long e) {
    this.primList.add(this.unwrap(e));
    return true;
  }
  @Override
  public Iterator<Long> iterator() {
    return this.listIterator();
  }
  @Override
  public boolean addAll(int idx, Collection<? extends Long> that) {
    return super.addAll(idx, that);
  }
  @Override
  public Long remove(int e) {
    return this.primList.remove(e);
  }
  @Override
  public void add(int index, Long e) {
    this.primList.insert(index, this.unwrap(e));
  }
  @Override
  public Long set(int p0, Long p1) {
    return super.set(p0, p1);
  }
  @Override
  public Long get(int index) {
    return this.wrap(this.primList.get(index));
  }
  @Override
  public String toString() {
    return this.primList.toString();
  }
  @Override
  public boolean retainAll(Collection<?> that) {
    return super.retainAll(that);
  }
  @Override
  public boolean removeAll(Collection<?> that) {
    return super.removeAll(that);
  }
  @Override
  public boolean addAll(Collection<? extends Long> that) {
    return super.addAll(that);
  }
  @Override
  public boolean containsAll(Collection<?> that) {
    return super.containsAll(that);
  }
  @Override
  public boolean remove(Object e) {
    return (e instanceof Long ? this.removePrim(this.unwrap(e)) : false);
  }
  @Override
  public <T extends Object> T[] toArray(T[] array) {
    return super.toArray(array);
  }
  @Override
  public Object[] toArray() {
    return super.toArray();
  }
  @Override
  public boolean contains(Object e) {
    return (e instanceof Long ? this.primList.contains(this.unwrap(e)) : false);
  }
  @Override
  public boolean isEmpty() {
    return this.primList.isEmpty();
  }
  public int size() {
    return this.primList.size();
  }
  public ListIterator<Long> listIterator(int index) {
    return new TLongListIterator(index);
  }
  protected boolean removePrim(long primValue) {
    int idx = this.primList.indexOf(primValue);
    if (idx >= 0) {
      this.primList.remove(idx);
      return true;
    }
    return false;
  }
  protected Long wrap(long primValue) {
    return Long.valueOf(primValue);
  }
  protected long unwrap(Object value) {
    return ((Long) value).longValue();
  }
  public class TLongListIterator implements ListIterator<Long> {
    private int nextIdx;
    public TLongListIterator(int startAt) {
      this.nextIdx = startAt;
    }
    public void add(Long e) {
      throw new UnsupportedOperationException();
    }
    public void set(Long e) {
      throw new UnsupportedOperationException();
    }
    public void remove() {
      TLongArrayListDecorator.this.primList.remove(this.nextIdx);
    }
    public int previousIndex() {
      return this.nextIdx - 1;
    }
    public int nextIndex() {
      return this.nextIdx;
    }
    public Long previous() {
      if (this.nextIdx > 0 && this.nextIdx <= TLongArrayListDecorator.this.primList.size()) {
        return TLongArrayListDecorator.this.wrap(TLongArrayListDecorator.this.primList.get(--this.nextIdx));
      }
      throw new NoSuchElementException();
    }
    public boolean hasPrevious() {
      return this.nextIdx > 0 && this.nextIdx <= TLongArrayListDecorator.this.primList.size();
    }
    public Long next() {
      if (this.nextIdx >= 0 && this.nextIdx < TLongArrayListDecorator.this.primList.size()) {
        return TLongArrayListDecorator.this.wrap(TLongArrayListDecorator.this.primList.get(this.nextIdx++));
      }
      throw new NoSuchElementException();
    }
    public boolean hasNext() {
      return this.nextIdx >= 0 && this.nextIdx < TLongArrayListDecorator.this.primList.size();
    }
  }
}
