示例#1
0
        /**
         * Constructs a CompoundVecBuffer with the specified initial capacity.
         *
         * @param capacity the CompoundVecBuffer's initial capacity, in number of sub-buffers.
         *
         * @throws ArgumentException if the capacity is less than 1.
         */
        public CompoundVecBuffer(int capacity)
        {
            if (capacity < 1)
            {
                String message = Logging.getMessage("generic.CapacityIsInvalid", capacity);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            this.capacity = capacity;
            this.offsets  = WWBufferUtil.newIntBuffer(capacity, ALLOCATE_DIRECT_BUFFERS);
            this.lengths  = WWBufferUtil.newIntBuffer(capacity, ALLOCATE_DIRECT_BUFFERS);
        }
示例#2
0
        protected CompoundVecBuffer(CompoundVecBuffer that, int[] indices, int offset, int length)
        {
            this.count    = length;
            this.capacity = length;

            this.offsets = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS);
            this.lengths = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS);

            for (int i = offset; i < offset + length; i++)
            {
                this.offsets.put(that.offsets.get(indices[i]));
                this.lengths.put(that.lengths.get(indices[i]));
            }

            this.offsets.rewind();
            this.lengths.rewind();
        }
示例#3
0
        protected void expandCapacity(int minCapacity)
        {
            int newCapacity = 2 * this.capacity;

            // If the new capacity overflows the range of 32-bit integers, then use the largest 32-bit integer.
            if (newCapacity < 0)
            {
                newCapacity = Integer.MAX_VALUE;
            }
            // If the new capacity is still not large enough for the minimum capacity specified, then just use the minimum
            // capacity specified.
            else if (newCapacity < minCapacity)
            {
                newCapacity = minCapacity;
            }

            this.offsets  = WWBufferUtil.copyOf(this.offsets, newCapacity);
            this.lengths  = WWBufferUtil.copyOf(this.lengths, newCapacity);
            this.capacity = newCapacity;
        }
示例#4
0
        protected CompoundVecBuffer(CompoundVecBuffer that, int beginIndex, int endIndex)
        {
            int length = endIndex - beginIndex + 1;

            this.count    = length;
            this.capacity = length;

            this.offsets = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS);
            that.offsets.limit(endIndex + 1);
            that.offsets.position(beginIndex);
            this.offsets.put(that.offsets);
            this.offsets.rewind();
            that.offsets.clear();

            this.lengths = WWBufferUtil.newIntBuffer(length, ALLOCATE_DIRECT_BUFFERS);
            that.lengths.limit(endIndex + 1);
            that.lengths.position(beginIndex);
            this.lengths.put(that.lengths);
            this.lengths.rewind();
            that.lengths.clear();
        }