/// <summary>Gets the value at the given index.</summary> protected override object Get(int index) { if (buffer == null) { // Use the _Buffer instead: return(LittleConverter.ToInt32(_Buffer.buffer, (index * 4) + ByteOffset)); } return(buffer[index]); }
/// <summary> /// Puts an unknown object into this array. /// Note that the value is always expected to be a value type. /// </summary> protected override void Set(int index, object value) { if (buffer == null) { // Use the _Buffer instead: LittleConverter.GetBytes((int)value, _Buffer.buffer, (index * 4) + ByteOffset); return; } // Get it as an int and put it in: buffer[index] = (int)value; }
protected override void FillBuffer() { int length = Length; int byteOffset = ByteOffset; for (int i = 0; i < length; i++) { var value = buffer[i]; LittleConverter.GetBytes(value, _Buffer.buffer, byteOffset); byteOffset += 4; } // Remove the fast buffer: buffer = null; }
/// <summary> /// Gets or sets the given entry in the array. /// </summary> public uint this[int index] { get{ if (buffer == null) { // Use the _Buffer instead: return(LittleConverter.ToUInt32(_Buffer.buffer, (index * 4) + ByteOffset)); } return(buffer[index]); } set{ if (buffer == null) { // Use the _Buffer instead: LittleConverter.GetBytes(value, _Buffer.buffer, (index * 4) + ByteOffset); return; } buffer[index] = value; } }