Ensure that the array representation has the necessary capacity.

@param capacity
the requested capacity
429318
@Override
    @SuppressWarnings("unchecked")
    protected void ensureCapacity(int capacity) {
        checkCapacity(capacity);
        K[] newArray = (K[]) new Object[capacity];
        System.arraycopy(array, 0, newArray, 0, size);
        array = newArray;
        BitSet newBitSet = new BitSet(capacity);
        newBitSet.or(reverse);
        reverse = newBitSet;
    }
444277
@Override
	// @NotThreadSafe
	protected void ensureCapacity(long capacity) throws IOException {
		long curCapacity = pbuffer.capacity();
		if(curCapacity<capacity) expandCapacity(curCapacity, capacity);
	}
834208
public void ensureCapacity(int capacity) {
        if (capacity > data.length) {
            int newCap = Math.max(data.length << 1, capacity);
            int[] tmp = new int[newCap];
            System.arraycopy(data, 0, tmp, 0, data.length);
            data = tmp;
        }
    }
507878
private void ensureCapacity() {
		if (size < selectionKeys.length) {
			return;
		}
		SelectionKey[] newArray = new SelectionKey[selectionKeys.length * 2];
		System.arraycopy(selectionKeys, 0, newArray, 0, size);
		selectionKeys = newArray;
	}
1372100
private final void ensureCapacity(int len) {
        if (value.length < len) {
            value = new int[len];
            offset = 0;
            intLen = len;
        }
    }
561984
protected void ensureCapacity() {
        if(_buffer.remaining() < 8) {
            ByteBuffer b = ByteBuffer.allocate(_buffer.capacity() << 1);
            _buffer.flip();
            b.put(_buffer);
            _buffer = b;
        }
    }
800104
public void setCapacity(long capacity) {
        if (capacity < MIN_HEADER_TABLE_SIZE || capacity > MAX_HEADER_TABLE_SIZE) {
            throw new IllegalArgumentException("capacity is invalid: " + capacity);
        }
        // initially capacity will be -1 so init won't return here
        if (this.capacity == capacity) {
            return;
        }
        this.capacity = capacity;

        if (capacity == 0) {
            clear();
        } else {
            // initially size will be 0 so remove won't be called
            while (size > capacity) {
                remove();
            }
        }

        int maxEntries = (int) (capacity / HpackHeaderField.HEADER_ENTRY_OVERHEAD);
        if (capacity % HpackHeaderField.HEADER_ENTRY_OVERHEAD != 0) {
            maxEntries++;
        }

        // check if capacity change requires us to reallocate the array
        if (hpackHeaderFields != null && hpackHeaderFields.length == maxEntries) {
            return;
        }

        HpackHeaderField[] tmp = new HpackHeaderField[maxEntries];

        // initially length will be 0 so there will be no copy
        int len = length();
        int cursor = tail;
        for (int i = 0; i < len; i++) {
            HpackHeaderField entry = hpackHeaderFields[cursor++];
            tmp[i] = entry;
            if (cursor == hpackHeaderFields.length) {
                cursor = 0;
            }
        }

        tail = 0;
        head = tail + len;
        hpackHeaderFields = tmp;
    }
1016100
public static IntBuffer allocate (int capacity) {
        if (capacity < 0) {
            throw new IllegalArgumentException();
        }
        ByteBuffer bb = ByteBuffer.allocateDirect(capacity * 4);
        bb.order(ByteOrder.nativeOrder());
        return bb.asIntBuffer();
    }
368901
private void ensure(final int newSize) {
    if (newSize >= this.elements.length) {
      final boolean[] newArray = new boolean[Math.max(newSize, this.size * 2)];
      System.arraycopy(this.elements, 0, newArray, 0, this.size);
      this.elements = newArray;
    }
  }
831697
public static <F> FullList<F> newListWithCapacity(final int capacity, final F... elements) {
		final FullList<F> l = new FullList<F>(null, capacity);
		l.addAll(Arrays.asList(elements));
		return l;
	}
1116659
@SuppressWarnings("unchecked")
  private void initialize(int capacity) {
    // Find a power of 2 >= capacity
    int tableLength = 16;
    while (tableLength < capacity) {
      tableLength <<= 1;
    }
    // Allocates hash table.
    _entries = new EntryImpl[tableLength];
    _mask = tableLength - 1;
    _capacity = capacity;
    _size = 0;
    // Allocates views.
    _values = new Values();
    _entrySet = new EntrySet();
    _keySet = new KeySet();
    // Resets pointers.
    _poolFirst = null;
    _mapFirst = null;
    _mapLast = null;
    // Allocates entries.
    for (int i = 0; i < capacity; i++) {
      EntryImpl<K, V> entry = new EntryImpl<K, V>();
      entry._after = _poolFirst;
      _poolFirst = entry;
    }
  }
1341845
@Check(CheckType.FAST)
	public void checkCapacityFeatures(SarlCapacity capacity) {
		if (capacity.getMembers().isEmpty()) {
			if (!isIgnored(DISCOURAGED_CAPACITY_DEFINITION)) {
				addIssue(Messages.SARLValidator_77,
						capacity,
						null,
						ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
						DISCOURAGED_CAPACITY_DEFINITION,
						capacity.getName(),
						"aFunction"); //$NON-NLS-1$
			}
		}
	}
772519
@Check
	public void checkContainerType(SarlCapacity capacity) {
		final XtendTypeDeclaration declaringType = capacity.getDeclaringType();
		if (declaringType != null) {
			final String name = canonicalName(declaringType);
			assert name != null;
			error(MessageFormat.format(Messages.SARLValidator_30, name),
					capacity,
					null,
					INVALID_NESTED_DEFINITION);
		}
	}
292873
public void ensureCapacity (int additionalCapacity) {
		int sizeNeeded = size + additionalCapacity;
		if (sizeNeeded >= threshold) resize(ObjectMap.nextPowerOfTwo((int)(sizeNeeded / loadFactor)));
	}
1363771
@Check(CheckType.NORMAL)
	public void checkMultipleCapacityUses(SarlCapacityUses uses) {
		if (!isIgnored(REDUNDANT_CAPACITY_USE)) {
			final XtendTypeDeclaration declaringType = uses.getDeclaringType();
			if (declaringType != null) {
				final Set<String> previousCapacityUses = doGetPreviousCapacities(uses,
						declaringType.getMembers().iterator());
				int index = 0;
				for (final JvmTypeReference capacity : uses.getCapacities()) {
					if (previousCapacityUses.contains(capacity.getIdentifier())) {
						addIssue(MessageFormat.format(
								Messages.SARLValidator_79,
								capacity.getSimpleName()),
								uses,
								SARL_CAPACITY_USES__CAPACITIES,
								index,
								REDUNDANT_CAPACITY_USE,
								capacity.getSimpleName());
					} else {
						previousCapacityUses.add(capacity.getIdentifier());
					}
					++index;
				}
			}
		}
	}
605497
public final void ensureCapacity( int targetCapacity )
    {
        if (targetCapacity > capacity)
        {
            int newLength = Math.max(capacity << 1, targetCapacity);
            byte[] copy = new byte[newLength];
            System.arraycopy(buf, 0, copy, 0, capacity);
            buf = copy;
            capacity = newLength;
        }
    }
122197
@Check(CheckType.FAST)
	public void checkSuperTypes(SarlCapacity capacity) {
		checkSuperTypes(
				capacity,
				SARL_CAPACITY__EXTENDS,
				capacity.getExtends(),
				Capacity.class,
				false);
	}