@SuppressWarnings("unchecked")
    @Override public PersistentVector<E> replace(int i, E val) {
        if (i >= 0 && i < size) {
            if (i >= tailoff()) {
                Object[] newTail = new Object[tail.length];
                System.arraycopy(tail, 0, newTail, 0, tail.length);
                newTail[i & LOW_BITS] = val;

                return new PersistentVector<>(size, shift, root, (E[]) newTail);
            }

            return new PersistentVector<>(size, shift, doAssoc(shift, root, i, val), tail);
        }
        if (i == size) {
            return append(val);
        }
        throw new IndexOutOfBoundsException();
    }
@SuppressWarnings("unchecked")
    @Override public PersistentVector<E> replace(int i, E val) {
        if (i >= 0 && i < size) {
            if (i >= tailoff()) {
                Object[] newTail = new Object[tail.length];
                System.arraycopy(tail, 0, newTail, 0, tail.length);
                newTail[i & LOW_BITS] = val;

                return new PersistentVector<>(size, shift, root, (E[]) newTail);
            }

            return new PersistentVector<>(size, shift, doAssoc(shift, root, i, val), tail);
        }
        if (i == size) {
            return append(val);
        }
        throw new IndexOutOfBoundsException();
    }
@ SuppressWarnings ( "unchecked" ) @ Override public PersistentVector < E > replace ( int i , E val ) { if ( i >= 0 && i < size ) { if ( i >= tailoff ( ) ) { Object [ ] newTail = new Object [ tail . length ] ; System . arraycopy ( tail , 0 , newTail , 0 , tail . length ) ; newTail [ i & LOW_BITS ] = val ; return new PersistentVector <> ( size , shift , root , ( E [ ] ) newTail ) ; } return new PersistentVector <> ( size , shift , doAssoc ( shift , root , i , val ) , tail ) ; } if ( i == size ) { return append ( val ) ; } throw new IndexOutOfBoundsException ( ) ; }
{@inheritDoc}
{