private static <K, V> HamtPMap<K, V>[] insertChild(
      HamtPMap<K, V>[] children, int index, HamtPMap<K, V> child) {
    @SuppressWarnings("unchecked") // only used internally.
    HamtPMap<K, V>[] newChildren = (HamtPMap<K, V>[]) new HamtPMap<?, ?>[children.length + 1];
    newChildren[index] = child;
    System.arraycopy(children, 0, newChildren, 0, index);
    System.arraycopy(children, index, newChildren, index + 1, children.length - index);
    return newChildren;
  }
private static < K , V > HamtPMap < K , V > [ ] insertChild ( HamtPMap < K , V > [ ] children , int index , HamtPMap < K , V > child ) { @ SuppressWarnings ( "unchecked" ) HamtPMap < K , V > [ ] newChildren = ( HamtPMap < K , V > [ ] ) new HamtPMap < ? , ? > [ children . length + 1 ] ; newChildren [ index ] = child ; System . arraycopy ( children , 0 , newChildren , 0 , index ) ; System . arraycopy ( children , index , newChildren , index + 1 , children . length - index ) ; return newChildren ; }
Returns a new array of children with an additional child inserted at the given index.