TransformedArray.java 1.5 KB

123456789101112131415161718192021222324252627282930313233
  1. package gnu.lists;
  2. /** Indexes are mapped. */
  3. public abstract class TransformedArray<E>
  4. extends AbstractSequence<E> implements Array<E> {
  5. // Most commonly base is a SimpleVector<E> but not always.
  6. protected Array<E> base;
  7. public TransformedArray() { }
  8. public TransformedArray(Array<E> base) { this.base = base; }
  9. public int getElementKind() { return base.getElementKind(); }
  10. public E getRowMajor(int index) { return Arrays.getRowMajor(this, index); }
  11. public E getRaw(int effi) { return base.getRaw(effi); }
  12. public boolean getBooleanRaw(int effi) { return base.getBooleanRaw(effi); }
  13. public byte getByteRaw(int effi) { return base.getByteRaw(effi); }
  14. public char getCharRaw(int effi) { return base.getCharRaw(effi); }
  15. public short getShortRaw(int effi) { return base.getShortRaw(effi); }
  16. public int getIntRaw(int effi) { return base.getIntRaw(effi); }
  17. public long getLongRaw(int effi) { return base.getLongRaw(effi); }
  18. public float getFloatRaw(int effi) { return base.getFloatRaw(effi); }
  19. public double getDoubleRaw(int effi) { return base.getDoubleRaw(effi); }
  20. public int getInt(int i) { return base.getIntRaw(effectiveIndex(i)); }
  21. public int getInt(int i, int j) { return base.getIntRaw(effectiveIndex(i, j)); }
  22. public void setRaw(int index, E value) { base.setRaw(index, value); }
  23. protected void checkCanWrite() {
  24. if (base instanceof AbstractSequence)
  25. ((AbstractSequence) base).checkCanWrite();
  26. }
  27. }