public void insert ( Token where , Token token ) { if ( where == null ) { // put at the front of the list if ( size == 0 ) push ( token ) ; else { first . previous = token ; token . previous = null ; token . next = first ; first = token ; size ++ ; } } else if ( where == last || null == last ) { push ( token ) ; } else { token . next = where . next ; token . previous = where ; where . next . previous = token ; where . next = token ; size ++ ; } }
Inserts token after where . if where is null then it is inserted to the beginning of the list .