sclass FloatBuffer is Iterable, IntSize { float[] data; int size; *() {} *(int size) { if (size != 0) data = new float[size]; } *(Iterable l) { addAll(l); } *(Cl l) { this(l(l)); addAll(l); } *(float... data) { this.data = data; size = l(data); } void add(float i) { if (size >= lFloatArray(data)) { data = resizeFloatArray(data, Math.max(1, toInt(Math.min(maximumSafeArraySize(), lFloatArray(data)*2L)))); if (size >= data.length) fail("FloatBuffer too large: " + size); } data[size++] = i; } void addAll(Iterable l) { if (l != null) for (float i : l) add(i); } float[] toArray() { ret size == 0 ? null : resizeFloatArray(data, size); } float[] toArrayNonNull() { ret unnull(toArray()); } L toList() { ret floatArrayToList(data, 0, size); } L asVirtualList() { ret new RandomAccessAbstractList { public int size() { ret size; } public Float get(int i) { ret FloatBuffer.this.get(i); } public Float set(int i, Float val) { Float a = get(i); data[i] = val; ret a; } }; } void reset { size = 0; } void clear { reset(); } public int size() { ret size; } bool isEmpty() { ret size == 0; } float get(int idx) { if (idx >= size) fail("Index out of range: " + idx + "/" + size); ret data[idx]; } void set(int idx, float value) { if (idx >= size) fail("Index out of range: " + idx + "/" + size); data[idx] = value; } float popLast() { if (size == 0) fail("empty buffer"); ret data[--size]; } float last() { ret data[size-1]; } float nextToLast() { ret data[size-2]; } toString { ret squareBracket(joinWithSpace(toList())); } public Iterator iterator() { ret new ItIt { int i = 0; public bool hasNext() { ret i < size; } public Float next() { //if (!hasNext()) fail("Index out of bounds: " + i); ret data[i++]; } }; } /*public FloatIterator floatIterator() { ret new FloatIterator { int i = 0; public bool hasNext() { ret i < size; } public int next() { //if (!hasNext()) fail("Index out of bounds: " + i); ret data[i++]; } toString { ret "Iterator@" + i + " over " + FloatBuffer.this; } }; }*/ void trimToSize { data = resizeFloatArray(data, size); } int indexOf(float b) { for i to size: if (data[i] == b) ret i; ret -1; } float[] subArray(int start, int end) { ret subFloatArray(data, start, min(end, size)); } }