@ SuppressWarnings ( "unchecked" ) void insert ( Suffix < T , S > suffix , ActivePoint < T , S > activePoint ) { Object item = suffix . getEndItem ( ) ; if ( edges . containsKey ( item ) ) { if ( tree . isNotFirstInsert ( ) && activePoint . getNode ( ) != tree . getRoot ( ) ) tree . setSuffixLink ( activePoint . getNode ( ) ) ; activePoint . setEdge ( edges . get ( item ) ) ; activePoint . incrementLength ( ) ; } else { saveSequenceTerminal ( item ) ; Edge < T , S > newEdge = new Edge <> ( suffix . getEndPosition ( ) - 1 , this , sequence , tree ) ; edges . put ( ( T ) suffix . getEndItem ( ) , newEdge ) ; suffix . decrement ( ) ; activePoint . updateAfterInsert ( suffix ) ; if ( tree . isNotFirstInsert ( ) && ! this . equals ( tree . getRoot ( ) ) ) { tree . getLastNodeInserted ( ) . setSuffixLink ( this ) ; } if ( suffix . isEmpty ( ) ) { } else tree . insert ( suffix ) ; } }
Inserts the suffix at the given active point .