private ClusteredArray <T> toClusteredArray(T[] plainArray) { ClusteredArray <T> cc = new ClusteredArray <T>(morphedLengthThreshold, plainArray.Length); cc.CopyFrom(plainArray, 0, 0, plainArray.Length); return(cc); }
public override ClusteredArray <byte> GetClusteredArray() { ClusteredArray <byte> clusterByteArray = new ClusteredArray <byte>(Length); clusterByteArray.CopyFrom(_data, 0, 0, Length); return(clusterByteArray); }
public bool MoveNext() { if (_dataWithValue != null && _index < _chunkKeys.Count) { object key = _chunkKeys[_index++]; if (_dataWithValue.ContainsKey(key)) { if (_getData) { _currentValue = new ClusteredArray <object>(2); _currentValue[0] = key; _currentValue[1] = _dataWithValue[key]; return(true); } else { _currentValue = new ClusteredArray <object>(1); _currentValue[0] = key; return(true); } } else { return(HasMoreData); } } return(HasMoreData); }
public void Dispose() { _keyList = null; _chunkKeys = null; _currentValue = null; _dataWithValue = null; }
public void Morph() { if (!isMorphed) { clusteredView = toClusteredArray(plainView); isMorphed = true; plainView = null; } }
public void DeMorph() { if (isMorphed) { plainView = (T[])clusteredView; isMorphed = false; clusteredView = null; } }
public void Deserialize(Runtime.Serialization.IO.CompactReader reader) { _columns = reader.ReadObject() as ColumnCollection; _objects = new ClusteredArray <object>(_columns.Count); for (int i = 0; i < _objects.Length; i++) { _objects[i] = reader.ReadObject(); } }
private void Dispose(bool disposing) { Close(); if (disposing) { GC.SuppressFinalize(this); } _currentRow = null; }
public bool Read() { if (_clientRecordSetEnumerator == null) { return(false); } bool next = _clientRecordSetEnumerator.MoveNext(); if (next) { _currentRow = _clientRecordSetEnumerator.Current; } return(next); }
static Crc32() { Table = new ClusteredArray <int>(256); for (uint i = 0; i < 256; i++) { uint crc = i; for (uint j = 0; j < 8; j++) { crc = (crc >> 1) ^ (((crc & 1) == 1) ? 0xEDB88320u : 0); } //Note: table ordinal and value inverted to omit -1 start and end operation Table[~i & 0x0ff] = ~unchecked ((int)crc); } }
public void Alternate() { switch (isMorphed) { case true: plainView = (T[])clusteredView; isMorphed = false; clusteredView = null; break; case false: clusteredView = toClusteredArray(plainView); isMorphed = true; plainView = null; break; } }
public static void SerializeClusteredArray <T>(ClusteredArray <T> array, Runtime.Serialization.IO.CompactWriter writer) { if (array == null) { writer.Write(false); return; } else { writer.Write(true); writer.Write(array.Length); writer.Write(array.LengthThreshold); for (int i = 0; i < array.Length; i++) { writer.WriteObject(array[i]); } } }
public virtual void ResetPool() { lock (_operationLock) { Count = _initialCapacity; Capacity = _initialCapacity; _pooledObjectStack = new ClusteredArray <T>(Capacity); for (int i = 0; i < Capacity; i++) { var instance = _pooledObjectStack[i] = GetInstanceSafe(); instance.ResetLeasable(); } _top = Capacity; _hits = 0; _misses = 0; _totalRequests = 0; } }
public static ClusteredArray <T> DeserializeClusteredArray <T>(Runtime.Serialization.IO.CompactReader reader) { bool flag = reader.ReadBoolean(); if (flag) { int length = reader.ReadInt32(); int threshold = reader.ReadInt32(); ClusteredArray <T> array = new ClusteredArray <T>(threshold, length); for (int i = 0; i < length; i++) { array[i] = (T)reader.ReadObject(); } return(array); } else { return(null); } }
public Morphable(T[][] arr) { if (arr != null) { if (arr.Length > 1) { morphedLengthThreshold = arr[0].Length; clusteredView = new ClusteredArray <T>(morphedLengthThreshold, arr[0].Length * arr.Length); } else { clusteredView = new ClusteredArray <T>(arr[0].Length); morphedLengthThreshold = clusteredView.LengthThreshold; } int arrayposition = 0; foreach (T[] buffer in arr) { clusteredView.CopyFrom(buffer, 0, arrayposition, buffer.Length); arrayposition += buffer.Length; } isMorphed = true; } }
public override ClusteredArray <byte> GetClusteredArray() { ClusteredArray <byte> clusterByteArray = new ClusteredArray <byte>(Length); int nextIndex = 0; byte[] binarChunk = null; if (Length > 0) { for (int i = 0; i < _data.Count - 1; i++) { binarChunk = (byte[])_data[i]; if (binarChunk != null) { clusterByteArray.CopyFrom(binarChunk, 0, nextIndex, binarChunk.Length); nextIndex += binarChunk.Length; } } clusterByteArray.CopyFrom((byte[])_data[_noOfChunks - 1], 0, nextIndex, _lastChunkSize); } return(clusterByteArray); }
public ClusteredMemoryStream(byte[] buffer, bool writable) { if (buffer == null) throw new ArgumentNullException("buffer", ResourceHelper.GetResourceString("ArgumentNull_Buffer")); #if DEBUG Contract.EndContractBlock(); #endif _buffer = new ClusteredArray<byte>(buffer.Length); _buffer.CopyFrom(buffer, 0, 0, buffer.Length); _length = _capacity = buffer.Length; _writable = writable; _exposable = false; _origin = 0; _isOpen = true; }
public ClusteredMemoryStream(int capacity) { if (capacity < 0) { throw new ArgumentOutOfRangeException("capacity", ResourceHelper.GetResourceString("ArgumentOutOfRange_NegativeCapacity")); } #if DEBUG Contract.EndContractBlock(); #endif _buffer = new ClusteredArray<byte>(capacity); _capacity = capacity; _expandable = true; _writable = true; _exposable = true; _origin = 0; // Must be 0 for byte[]'s created by MemoryStream _isOpen = true; }
internal RecordRow(ColumnCollection columns) { _columns = columns; _objects = new ClusteredArray <object>(columns.Count); }
// Constructs a ArrayList with a given initial capacity. The list is // initially empty, but will have room for the given number of elements // before any reallocations are required. // public ClusteredArrayList(int capacity) { if (capacity < 0) throw new ArgumentOutOfRangeException("capacity", ResourceHelper.GetResourceString("ArgumentOutOfRange_MustBeNonNegNum")); #if DEBUG Contract.EndContractBlock(); #endif if (capacity == 0) _items = emptyArray; else _items = new ClusteredArray<object>(capacity); }
// Constructs a ArrayList, copying the contents of the given collection. The // size and capacity of the new list will both be equal to the size of the // given collection. // public ClusteredArrayList(ICollection c) { if (c == null) throw new ArgumentNullException("c", ResourceHelper.GetResourceString("ArgumentNull_Collection")); #if DEBUG Contract.EndContractBlock(); #endif int count = c.Count; if (count == 0) { _items = emptyArray; } else { _items = new ClusteredArray<object>(count); AddRange(c); } }
public Morphable(ClusteredArray <T> arr) { clusteredView = arr; morphedLengthThreshold = arr.LengthThreshold; isMorphed = true; }
public ClusteredArrayList() { _items = emptyArray; }
//Changelog: Used ClusteredArray's internal CopyFrom method. public ClusteredMemoryStream(byte[] buffer, int index, int count, bool writable, bool publiclyVisible) { if (buffer == null) throw new ArgumentNullException("buffer", ResourceHelper.GetResourceString("ArgumentNull_Buffer")); if (index < 0) throw new ArgumentOutOfRangeException("index", ResourceHelper.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (count < 0) throw new ArgumentOutOfRangeException("count", ResourceHelper.GetResourceString("ArgumentOutOfRange_NeedNonNegNum")); if (buffer.Length - index < count) throw new ArgumentException(ResourceHelper.GetResourceString("Argument_InvalidOffLen")); #if DEBUG Contract.EndContractBlock(); #endif _buffer = new ClusteredArray<byte>(buffer.Length); _buffer.CopyFrom(buffer, 0, 0, buffer.Length); _origin = _position = index; _length = _capacity = index + count; _writable = writable; _exposable = publiclyVisible; // Can GetBuffer return the array? _expandable = false; _isOpen = true; }