private static < K , V > HamtPMap < K , V > [ ] deleteChild ( HamtPMap < K , V > [ ] children , int index ) { if ( children . length == 1 ) { // Note: index should always be zero. return emptyChildren ( ) ; } @ SuppressWarnings ( "unchecked" ) // only used internally. HamtPMap < K , V > [ ] newChildren = ( HamtPMap < K , V > [ ] ) new HamtPMap < ? , ? > [ children . length - 1 ] ; System . arraycopy ( children , 0 , newChildren , 0 , index ) ; System . arraycopy ( children , index + 1 , newChildren , index , children . length - index - 1 ) ; return newChildren ; }
Returns a new array of children with the child at the given index deleted .