Exemplo n.º 1
0
 public ClusteredArrayList()
 {
     _items = emptyArray;
 }
Exemplo n.º 2
0
        // 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);
            }
        }
Exemplo n.º 3
0
        // 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);
        }
Exemplo n.º 4
0
        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;
        }
Exemplo n.º 5
0
        //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;
        }
Exemplo n.º 6
0
        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;
        }