@Override public void writeRange( int startElement, int count, AttributeStreamBase _src, int srcStart, boolean bForward, int stride) { if (startElement < 0 || count < 0 || srcStart < 0) throw new IllegalArgumentException(); if (!bForward && (stride <= 0 || (count % stride != 0))) throw new IllegalArgumentException(); AttributeStreamOfInt32 src = (AttributeStreamOfInt32) _src; // the input // type must // match if (src.size() < (int) (srcStart + count)) throw new IllegalArgumentException(); if (count == 0) return; if (size() < count + startElement) resize(count + startElement); if (_src == (AttributeStreamBase) this) { _selfWriteRangeImpl(startElement, count, srcStart, bForward, stride); return; } if (bForward) { System.arraycopy(src.m_buffer, srcStart, m_buffer, startElement, count); // int j = startElement; // int offset = srcStart; // for (int i = 0; i < count; i++) // { // m_buffer[j] = src.m_buffer[offset]; // j++; // offset++; // } } else { int j = startElement; int offset = srcStart + count - stride; if (stride == 1) { for (int i = 0; i < count; i++) { m_buffer[j] = src.m_buffer[offset]; j++; offset--; } } else { for (int i = 0, n = count / stride; i < n; i++) { for (int k = 0; k < stride; k++) m_buffer[j + k] = src.m_buffer[offset + k]; j += stride; offset -= stride; } } } }
public AttributeStreamOfInt32(AttributeStreamOfInt32 other, int maxSize) { m_size = other.size(); if (m_size > maxSize) m_size = maxSize; int sz = m_size; if (sz < 2) sz = 2; m_buffer = new int[sz]; System.arraycopy(other.m_buffer, 0, m_buffer, 0, m_size); }
@Override public boolean equals(AttributeStreamBase other, int start, int end) { if (other == null) return false; if (!(other instanceof AttributeStreamOfInt32)) return false; AttributeStreamOfInt32 _other = (AttributeStreamOfInt32) other; int size = size(); int sizeOther = _other.size(); if (end > size || end > sizeOther && (size != sizeOther)) return false; if (end > size) end = size; for (int i = start; i < end; i++) if (read(i) != _other.read(i)) return false; return true; }