private void resize(int newCapacity)
        {
            // assert (newCapacity & -newCapacity) == newCapacity; // power of 2
            int newLength = newCapacity * 2;

            Object[] oldTable = table;
            int oldLength = oldTable.length;
            if (oldLength == 2 * MAXIMUM_CAPACITY)
            { // can't expand any further
                if (threshold == MAXIMUM_CAPACITY - 1)
                    throw new IllegalStateException("Capacity exhausted.");
                threshold = MAXIMUM_CAPACITY - 1; // Gigantic map!
                return;
            }
            if (oldLength >= newLength)
                return;

            Object[] newTable = new Object[newLength];
            threshold = newLength / 3;

            for (int j = 0; j < oldLength; j += 2)
            {
                Object key = oldTable[j];
                if (key != null)
                {
                    Object value = oldTable[j + 1];
                    oldTable[j] = null;
                    oldTable[j + 1] = null;
                    int i = hash(key, newLength);
                    while (newTable[i] != null)
                        i = nextKeyIndex(i, newLength);
                    newTable[i] = key;
                    newTable[i + 1] = value;
                }
            }
            table = newTable;
        }
Resize the table to hold given capacity.

@param newCapacity
           the new capacity, must be a power of two.
protostuff-core/src/main/java/io/protostuff/GraphProtostuffOutput.java