int [ ] getIndices ( final Literal literal ) { // Check whether the answer is already in the cache final int index = literal . getIndex ( ) ; final int [ ] cached = myIndices [ index ] ; if ( cached != null ) { return cached ; } // Find all indices final int [ ] values = findIndices ( literal ) ; myIndices [ index ] = values ; return values ; }
Returns all indices where the literal argument can be found in this String . Results are cached for better performance .