I can only think of one way off the top of my head:

class IndexedDocument {
    HashTable<String, int> index;
    String contents;

   /// Build an index of words and their position in the document
    void buildIndex() {
        for each word in document {
           add word, position to index
        }
    }
    Boolean searchFor(String word) {
         // use inxed to look up
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to