import java.util.Map;
import java.util.Set;
import java.util.HashMap;
import java.util.HashSet;

public class FileProfiler {
    private Map<String, Set<Integer>> wordRefs;
    
    public FileProfiler() {
    	this.wordRefs = new HashMap<String, Set<Integer>>();
    }
    
    public void addWord(String word, Integer lineNum) {
    	if (!this.wordRefs.containsKey(word)) {
    		this.wordRefs.put(word, new HashSet<Integer>());
    	}
    	this.wordRefs.get(word).add(lineNum);
    }
    
    public Set<Integer> lookup(String word) {
    	if (this.wordRefs.containsKey(word)) {
    		return this.wordRefs.get(word);
    	}
    	else {
    		return new HashSet<Integer>();
    	}
    }
    
    public static void main(String[] args) {
    	FileProfiler words = new FileProfiler();
    	words.addWord("the", 1);
    	words.addWord("and", 1);
    	words.addWord("the", 2);
    	words.addWord("of", 3);
    	
    	System.out.println(words.lookup("the"));
    	System.out.println(words.lookup("and"));   
    	System.out.println(words.lookup("of"));
    	System.out.println(words.lookup("foo"));    	
    }
}
