////////////////////////////////////////////////////////////////////////////// public static IntArraySliceObj Create(long value) { long[] buffer = new long[32]; buffer[0] = value; PaddedIntArray paddedArray = new PaddedIntArray(buffer, 1); return(paddedArray.Slice(0, 1)); }
public IntArraySliceObj(PaddedIntArray source, long[] elts, int offset, int len) { data = SeqObjData((uint)len); extraData = NeSeqObjExtraData(); longs = elts; this.offset = offset; this.source = source; }
public static IntArraySliceObj Create(NeIntSeqObj seq, long value) { int len = seq.GetSize(); int size = MinBufferSize(len + 1); long[] buffer = new long[size]; seq.Copy(0, len, buffer, 0); buffer[len] = value; PaddedIntArray paddedArray = new PaddedIntArray(buffer, len + 1); return(paddedArray.Slice(0, len + 1)); }
public static IntArraySliceObj Create(NeIntSeqObj left, NeIntSeqObj right) { int leftLen = left.GetSize(); int rightLen = right.GetSize(); int len = leftLen + rightLen; int size = MinBufferSize(len); long[] buffer = new long[size]; left.Copy(0, leftLen, buffer, 0); right.Copy(0, rightLen, buffer, leftLen); PaddedIntArray paddedArray = new PaddedIntArray(buffer, len); return(paddedArray.Slice(0, len)); }
public /*synchronized*/ IntArraySliceObj Concat(int idx, NeIntSeqObj seq) { int seqLen = seq.GetSize(); int newLen = idx + seqLen; if (newLen > buffer.Length) { // We run out of space, expanding the array buffer int size = MinBufferSize(newLen); long[] newBuffer = new long[size]; for (int i = 0; i < idx; i++) { newBuffer[i] = buffer[i]; } seq.Copy(0, seqLen, newBuffer, idx); PaddedIntArray newArray = new PaddedIntArray(newBuffer, newLen); return(newArray.Slice(0, newLen)); //## THINK ABOUT THIS. WOULD IT WORK? // buffer = newBuffer; // used = newLen; // return new IntArraySliceObj(this, buffer, 0, used); } else if (idx == used) { // There's space for the new elements seq.Copy(0, seqLen, buffer, idx); used = newLen; return(new IntArraySliceObj(this, buffer, 0, used)); } else { // The next slot was already taken. This is supposed to happen only rarely Debug.Assert(idx < used & idx < buffer.Length); long[] newBuffer = new long[buffer.Length]; for (int i = 0; i < idx; i++) { newBuffer[i] = buffer[i]; } seq.Copy(0, seqLen, newBuffer, idx); PaddedIntArray newArray = new PaddedIntArray(newBuffer, newLen); return(newArray.Slice(0, newLen)); } }
public /*synchronized*/ IntArraySliceObj Append(int idx, long value) { if (idx == buffer.Length) { // We run out of space, expanding the array buffer int size = buffer.Length; int newSize = 2 * size; long[] newBuffer = new long[newSize]; for (int i = 0; i < size; i++) { newBuffer[i] = buffer[i]; } newBuffer[idx] = value; PaddedIntArray newArray = new PaddedIntArray(newBuffer, idx + 1); return(newArray.Slice(0, idx + 1)); //## THINK ABOUT THIS. WOULD IT WORK? // buffer = newBuffer; // used++; // return new IntArraySliceObj(this, buffer, 0, used); } else if (idx == used) { // There's space for the new element buffer[idx] = value; used++; return(new IntArraySliceObj(this, buffer, 0, used)); } else { // The next slot was already taken. This is supposed to happen only rarely Debug.Assert(idx < used & idx < buffer.Length); long[] newBuffer = new long[buffer.Length]; for (int i = 0; i < idx; i++) { newBuffer[i] = buffer[i]; } newBuffer[idx] = value; PaddedIntArray newArray = new PaddedIntArray(newBuffer, idx + 1); return(newArray.Slice(0, idx + 1)); } }
internal static IntArraySliceObj Concat(NeIntSeqObj left, NeIntSeqObj right) { return(PaddedIntArray.Create(left, right)); }
internal static IntArraySliceObj Append(NeIntSeqObj seq, long value) { return(PaddedIntArray.Create(seq, value)); }
internal static IntArraySliceObj CreateRightPadded(long value) { return(PaddedIntArray.Create(value)); }