public override ClusteredArray <byte> GetClusteredArray() { ClusteredArray <byte> clusterByteArray = new ClusteredArray <byte>(Length); clusterByteArray.CopyFrom(_data, 0, 0, Length); return(clusterByteArray); }
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); 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 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; } }
//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; }
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; }