public Double get(int index, Point center) { //Optimize for an iteration having a monotonic index: int startingPoint = currentIterator; for ( ; currentIterator < orderedEntries.size(); currentIterator++ ) { HitEntry currentEntry = orderedEntries.get( currentIterator ); if ( currentEntry == null ) { break; } if ( currentEntry.documentId == index ) { return currentEntry.getDistance( center ); } } //No match yet! scan the remaining section from the beginning: for ( currentIterator = 0; currentIterator < startingPoint; currentIterator++ ) { HitEntry currentEntry = orderedEntries.get( currentIterator ); if ( currentEntry == null ) { break; } if ( currentEntry.documentId == index ) { return currentEntry.getDistance( center ); } } throw new SearchException( "Unexpected index: this documentId was not collected" ); }
public Double get(int index, Point center) { //Optimize for an iteration having a monotonic index: int startingPoint = currentIterator; for ( ; currentIterator < orderedEntries.size(); currentIterator++ ) { HitEntry currentEntry = orderedEntries.get( currentIterator ); if ( currentEntry == null ) { break; } if ( currentEntry.documentId == index ) { return currentEntry.getDistance( center ); } } //No match yet! scan the remaining section from the beginning: for ( currentIterator = 0; currentIterator < startingPoint; currentIterator++ ) { HitEntry currentEntry = orderedEntries.get( currentIterator ); if ( currentEntry == null ) { break; } if ( currentEntry.documentId == index ) { return currentEntry.getDistance( center ); } } throw new SearchException( "Unexpected index: this documentId was not collected" ); }