1 11 package org.eclipse.core.internal.indexing; 12 13 class FieldArray { 14 15 protected Buffer buffer; protected int offset; protected int length; protected int stride; protected int count; 21 29 public FieldArray(Buffer buffer, int offset, int length, int stride, int count) { 30 this.buffer = buffer; 31 this.offset = offset; 32 this.length = length; 33 this.stride = stride; 34 this.count = count; 35 } 36 37 40 public Field fieldAt(int i) { 41 if (i >= count) 42 throw new ArrayIndexOutOfBoundsException (); 43 return new Field(buffer, offset + (i * stride), length); 44 } 45 46 49 public Field insert(int i) { 50 count++; 51 if (i >= count) 52 throw new ArrayIndexOutOfBoundsException (); 53 int s = offset + (i * stride); int t = s + stride; int n = (count - (i + 1)) * stride; buffer.copyInternal(s, t, n); 57 return fieldAt(i).clear(); 58 } 59 60 63 public void remove(int i) { 64 if (i >= count) 65 throw new ArrayIndexOutOfBoundsException (); 66 int s = offset + ((i + 1) * stride); int t = s - stride; int n = (count - (i + 1)) * stride; buffer.copyInternal(s, t, n); 70 fieldAt(count - 1).clear(); 71 count--; 72 } 73 } 74 | Popular Tags |