Increase the storage of this {@link EpollEventArray}.
175234
void increase() {
        // double the size
        length <<= 1;
        // There is no need to preserve what was in the memory before.
        ByteBuffer buffer = Buffer.allocateDirectWithNativeOrder(calculateBufferCapacity(length));
        Buffer.free(memory);
        memory = buffer;
        memoryAddress = Buffer.memoryAddress(buffer);
    }
126607
public synchronized void expand(int additionalCapacity) {
        if (additionalCapacity <= 0) {
            throw new IllegalArgumentException();
        }

        synchronized (lock) { // D312598
            final Object[] newBuffer = new Object[buffer.length + additionalCapacity];

            // PK53203 - put() acquires two locks in sequence. First, it acquires
            // the insert lock to update putIndex. Then, it drops the insert lock
            // and acquires the extract lock to update numberOfUsedSlots. As a
            // result, there is a window where putIndex has been updated, but
            // numberOfUsedSlots has not. Consequently, even though we have
            // acquired both locks in this method, we cannot rely on the values in
            // numberOfUsedSlots; we can only rely on putIndex and takeIndex.

            if (putIndex > takeIndex) {
                // The contents of the buffer do not wrap round
                // the end of the array. We can move its contents
                // into the new expanded buffer in one go.

                int used = putIndex - takeIndex;
                System.arraycopy(buffer, takeIndex, newBuffer, 0, used);
                putIndex = used;

                // PK53203.1 - If putIndex == takeIndex, then the buffer is either
                // completely full or completely empty. If it is completely full, then
                // we need to copy and adjust putIndex. Otherwise, we need to set
                // putIndex to 0.
            } else if (putIndex != takeIndex || buffer[takeIndex] != null) {
                // The contents of the buffer wrap round the end
                // of the array. We have to perform two copies to
                // move its contents into the new buffer.

                int used = buffer.length - takeIndex;
                System.arraycopy(buffer, takeIndex, newBuffer, 0, used);
                System.arraycopy(buffer, 0, newBuffer, used, putIndex);
                putIndex += used;
            } else {
                putIndex = 0;
            }

            // The contents of the buffer now begin at 0 - update the head pointer.

            takeIndex = 0;

            // The buffer's capacity has been increased so update the count of the
            // empty slots to reflect this.
            buffer = newBuffer;
        } // D312598
    }
430582
@Override
  protected final void increaseNewListSize() throws IOException {
    // register old situation
    int tmpOldSize = newKeyList.length;
    int tmpNewPosition = newPosition;
    // increase
    super.increaseNewListSize();
    // reconstruct
    T1[] tmpNewBasicValueList = newBasicValueSumList;
    long[] tmpNewBasicValueNList = newBasicValueNList;
    newBasicValueSumList = operations.createVector1(newSize);
    newBasicValueNList = new long[newSize];
    newPosition = tmpNewPosition;
    System.arraycopy(tmpNewBasicValueList, 0, newBasicValueSumList, 0,
        tmpOldSize);
    System.arraycopy(tmpNewBasicValueNList, 0, newBasicValueNList, 0,
        tmpOldSize);
  }
985083
public void putAll(ArrayMap<? extends K, ? extends V> array) {
        final int N = array.mSize;
        ensureCapacity(mSize + N);
        if (mSize == 0) {
            if (N > 0) {
                System.arraycopy(array.mHashes, 0, mHashes, 0, N);
                System.arraycopy(array.mArray, 0, mArray, 0, N<<1);
                mSize = N;
            }
        } else {
            for (int i=0; i<N; i++) {
                put(array.keyAt(i), array.valueAt(i));
            }
        }
    }
1086063
@Override
    public void storeUpdate(INDArray array, int iterationNumber, int epochNumber) {
        /*
            Here we want to do 4 things:
            1) update accumulated values
            2) invoke extractor, that'll (optionally) pull all updates above threshold
            3) ???
            4) PROFIT!
         */

        try {
            // commit should happen in each individual thread
            Nd4j.getExecutioner().commit();
            firstOne.compareAndSet(-1L, Thread.currentThread().getId());

            // TODO: since we know number of elements in advance, we don't really need CopyOnWrite list here.
            candidates.add(array);
            barrier.await();

            if (firstOne.get() == Thread.currentThread().getId()) {
                // if accum is null, let's just create it here
                if (storage == null) {
                    // we don't want state array to be attached to any workspace
                    shape = array.shape();
                    ordering = array.ordering();

                    try (MemoryWorkspace workspace = Nd4j.getMemoryManager().scopeOutOfWorkspaces()) {
                        // TODO: if p2p isn't supported, this should become HOST-only allocation
                        storage = Nd4j.create(shape, ordering);
                    }
                }


                // accumulate our values, a
                //storage.addi(array);
                Nd4j.accumulate(storage, candidates);

                // we ensure storage was updated successfully
                Nd4j.getExecutioner().commit();

                // if there's something to send - send it. Skip otherwise!!!
                if (handler.broadcastUpdates(storage, iterationNumber, epochNumber)) {
                    ownCounter.getAndIncrement();
                }

                // reset "first one" :)
                firstOne.set(-1L);
                candidates.clear();
            }

            barrier.await();
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            throw new RuntimeException(e);
        } catch (BrokenBarrierException e) {
            throw new RuntimeException(e);
        }
    }
1139762
public boolean Add(T value) {
        if (m_Count < m_Capacity) {
            m_Array[++m_Count] = value;
            UpHeap();
        }
        else if (greaterThan(m_Array[1], value)) {
            m_Array[1] = value;
            DownHeap();
        }
        else return false;
        return true;
    }
727231
private void grow() {
        final Activation[] elements = new Activation[this.elements.length * 2];
        System.arraycopy( this.elements,
                          0,
                          elements,
                          0,
                          this.elements.length );
        this.elements = elements;
    }
432515
private void growSize() {
		size++;

		if (size > maxSize) {
			if (keys.length == Integer.MAX_VALUE) {
				throw new IllegalStateException("Max capacity reached at size=" + size);
			}

			// Double the capacity.
			rehash(keys.length << 1);
		}
	}
539013
private static void allocateNodeLengths(final int[] array) {
        int firstNode = array.length - 2;
        int nextNode = array.length - 1;

        for (int currentDepth = 1, availableNodes = 2; availableNodes > 0; currentDepth++) {
            final int lastNode = firstNode;
            firstNode = first(array, lastNode - 1, 0);

            for (int i = availableNodes - (lastNode - firstNode); i > 0; i--) {
                array[nextNode--] = currentDepth;
            }

            availableNodes = (lastNode - firstNode) << 1;
        }
    }
330590
public void append(int[] i) {
        // could simply delegate to the other append methods, but this
        // (avoiding repeated comparisions) is more efficient.
        while (currentSize + i.length > buffer.length) {
            grow();
        }
        System.arraycopy(i, 0, buffer, currentSize, i.length);
        currentSize += i.length;
    }
1335100
protected void grow() {
    if(dists == EMPTY_DISTS) {
      dists = new double[INITIAL_SIZE];
      ids = new int[INITIAL_SIZE];
      return;
    }
    final int len = dists.length;
    final int newlength = len + (len >> 1) + 1;
    double[] odists = dists;
    dists = new double[newlength];
    System.arraycopy(odists, 0, dists, 0, odists.length);
    int[] oids = ids;
    ids = new int[newlength];
    System.arraycopy(oids, 0, ids, 0, oids.length);
  }
1220202
def _appendstore(self, store):
        """"""
        if not store.bitlength:
            return
        # Set new array offset to the number of bits in the final byte of current array.
        store = offsetcopy(store, (self.offset + self.bitlength) % 8)
        if store.offset:
            # first do the byte with the join.
            joinval = (self._rawarray.pop() & (255 ^ (255 >> store.offset)) |
                       (store.getbyte(0) & (255 >> store.offset)))
            self._rawarray.append(joinval)
            self._rawarray.extend(store._rawarray[1:])
        else:
            self._rawarray.extend(store._rawarray)
        self.bitlength += store.bitlength
694794
protected final void expand (int needed)
    {
        int ocapacity = _buffer.capacity();
        int ncapacity = _buffer.position() + needed;
        if (ncapacity > ocapacity) {
            // increase the buffer size in large increments
            ncapacity = Math.max(ocapacity << 1, ncapacity);
            ByteBuffer newbuf = ByteBuffer.allocate(ncapacity);
            newbuf.put((ByteBuffer)_buffer.flip());
            _buffer = newbuf;
        }
    }
767513
public final void increaseReadBufferSize() {
        if (AbstractIoSessionConfig.ENABLE_BUFFER_SIZE) {
            System.out.println("AbstractIoSession.increaseReadBufferSize()");
            int newReadBufferSize = getConfig().getReadBufferSize() << 1;
            if (newReadBufferSize <= getConfig().getMaxReadBufferSize()) {
                getConfig().setReadBufferSize(newReadBufferSize);
            } else {
                getConfig().setReadBufferSize(getConfig().getMaxReadBufferSize());
            }
        }

        deferDecreaseReadBuffer = true;
    }
156737
@Override
    protected void grow()
    {
        int newSize = newSize();
        ring = (double[]) newArray(ring, size, new double[newSize]);
        size = newSize;
    }
343785
@Override
  protected final void increaseNewListSize() throws IOException {
    // register old situation
    int tmpOldSize = newKeyList.length;
    int tmpNewPosition = newPosition;
    // increase
    super.increaseNewListSize();
    // reconstruct
    T1[][] tmpNewFullValueList = newFullValueList;
    newFullValueList = operations.createMatrix1(newSize);
    newPosition = tmpNewPosition;
    System.arraycopy(tmpNewFullValueList, 0, newFullValueList, 0, tmpOldSize);
  }
1124559
public int addValue(boolean[] array) {
        int val = hashCode();
        for (boolean b : array) {
            val = addValue(b);
        }
        return val;
    }