class SelectedSelectionKeySet extends AbstractSet<SelectionKey> {
    /** */
    private SelectionKey[] keysA;

    /** */
    private int keysASize;

    /** */
    private SelectionKey[] keysB;

    /** */
    private int keysBSize;

    /** */
    private boolean isA = true;

    /**
     *
     */
    SelectedSelectionKeySet() {
        keysA = new SelectionKey[1024];
        keysB = keysA.clone();
    }

    /** {@inheritDoc} */
    @Override public boolean add(SelectionKey o) {
        if (o == null)
            return false;

        if (isA) {
            int size = keysASize;
            keysA[size++] = o;
            keysASize = size;
            if (size == keysA.length)
                doubleCapacityA();
        }
        else {
            int size = keysBSize;
            keysB[size++] = o;
            keysBSize = size;
            if (size == keysB.length)
                doubleCapacityB();
        }

        return true;
    }

    /**
     *
     */
    private void doubleCapacityA() {
        SelectionKey[] newKeysA = new SelectionKey[keysA.length << 1];
        System.arraycopy(keysA, 0, newKeysA, 0, keysASize);
        keysA = newKeysA;
    }

    /**
     *
     */
    private void doubleCapacityB() {<FILL_FUNCTION_BODY>}

    /**
     * @return Selection keys.
     */
    SelectionKey[] flip() {
        if (isA) {
            isA = false;
            keysA[keysASize] = null;
            keysBSize = 0;
            return keysA;
        }
        else {
            isA = true;
            keysB[keysBSize] = null;
            keysASize = 0;
            return keysB;
        }
    }

    /** {@inheritDoc} */
    @Override public int size() {
        if (isA)
            return keysASize;
        else
            return keysBSize;
    }

    /** {@inheritDoc} */
    @Override public boolean remove(Object o) {
        return false;
    }

    /** {@inheritDoc} */
    @Override public boolean contains(Object o) {
        return false;
    }

    /** {@inheritDoc} */
    @Override public Iterator<SelectionKey> iterator() {
        throw new UnsupportedOperationException();
    }
}

        SelectionKey[] newKeysB = new SelectionKey[keysB.length << 1];
        System.arraycopy(keysB, 0, newKeysB, 0, keysBSize);
        keysB = newKeysB;
    
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>