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

com.github.methylene.lists.EmptyLookupList Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package com.github.methylene.lists;

import com.github.methylene.sym.Permutation;
import com.github.methylene.sym.Util;

import java.io.Serializable;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.RandomAccess;

class EmptyLookupList extends LookupList implements RandomAccess, Serializable {

  private static final long serialVersionUID = 1L;
  static final LookupList INSTANCE = new EmptyLookupList();

  private EmptyLookupList() {
    super(Permutation.identity(), Permutation.identity());
  }

  @Override public List sort() {
    return this;
  }

  @Override public List sortUnique() {
    return this;
  }

  @Override public Map group() {
    return Collections.emptyMap();
  }

  @Override public LookupList shuffle(Permutation p) {
    return this;
  }

  @Override public boolean isUnique() {
    return true;
  }

  @Override public boolean isSorted() {
    return true;
  }

  @Override public int[] indexOf(E el, int size) {
    return Util.INT_0;
  }

  @Override public E get(int i) {
    throw new ArrayIndexOutOfBoundsException();
  }

  @Override public int size() {
    return 0;
  }

}