try that example:
IntDict inventory;
String[] lines, words;
String find = "Lorem";
boolean gotit = false;
long startT, stopT, dT;
void setup() {
size(200, 200);
inventory = new IntDict();
lines = loadStrings("http://websitetips.com/articles/copy/lorem/ipsum.txt");
for ( String l : lines ) {
words = split(l, ' ');
for ( String word : words ) inventory.add(word, 1);
}
println(inventory);
println("we have "+inventory.size()+" entries");
startT = millis();
inventory.sortKeys(); // sort alphabetically
gotit = inventory.hasKey(find); // look for search string
stopT = millis();
dT = stopT - startT;
if ( gotit ) {
println("Yes, we found _" + find + "_: " + inventory.get(find) + " times");
} else {
println("Sorry, no _" + find + "_");
}
println(" and needed for sort and search " + dT + " msec" );
}
results:
IntDict size=131 { "Lorem": 19, "ipsum": 19, "dolor": 22, "sit": 19, "amet,": 10, "consetetur": 8, "sadipscing": 9, "elitr,": 9, "sed": 19, "diam": 19, "nonumy": 9, "eirmod": 9, "tempor": 10, "invidunt": 9, "ut": 13, "labore": 9, "et": 40, "dolore": 16, "magna": 11, "aliquyam": 9, "erat,": 8, "voluptua.": 8, "At": 9, "vero": 11, "eos": 9, "accusam": 9, "justo": 9, "duo": 9, "dolores": 9, "ea": 11, "rebum.": 9, "Stet": 9, "clita": 9, "kasd": 9, "gubergren,": 9, "no": 9, "sea": 9, "takimata": 9, "sanctus": 9, "est": 9, "amet.": 9, "": 8, "Duis": 3, "autem": 3, "vel": 6, "eum": 3, "iriure": 3, "in": 6, "hendrerit": 3, "vulputate": 3, "velit": 3, "esse": 3, "molestie": 3, "consequat,": 3, "illum": 3, "eu": 3, "feugiat": 3, "nulla": 5, "facilisis": 2, "at": 2, "eros": 2, "accumsan": 2, "iusto": 2, "odio": 2, "dignissim": 2, "qui": 2, "blandit": 2, "praesent": 2, "luptatum": 2, "zzril": 2, "delenit": 2, "augue": 2, "duis": 2, "te": 2, "feugait": 2, "facilisi.": 2, "consectetuer": 2, "adipiscing": 2, "elit,": 2, "nonummy": 2, "nibh": 2, "euismod": 2, "tincidunt": 2, "laoreet": 2, "aliquam": 2, "erat": 2, "volutpat.": 2, "Ut": 2, "wisi": 2, "enim": 2, "ad": 2, "minim": 2, "veniam,": 2, "quis": 2, "nostrud": 2, "exerci": 2, "tation": 2, "ullamcorper": 2, "suscipit": 2, "lobortis": 2, "nisl": 2, "aliquip": 2, "ex": 2, "commodo": 2, "consequat.": 2, "Nam": 1, "liber": 1, "cum": 1, "soluta": 1, "nobis": 1, "eleifend": 1, "option": 1, "congue": 1, "nihil": 1, "imperdiet": 1, "doming": 1, "id": 1, "quod": 1, "mazim": 1, "placerat": 1, "facer": 1, "possim": 1, "assum.": 1, "facilisis.": 1, "erat.": 1, "Consetetur": 1, "--------------------------------------------": 2, "Courtesy": 1, "of": 1, "WebsiteTips.com": 1, "http://websitetips.com/articles/copy/lorem/": 1 }
we have 131 entries
Yes, we found _Lorem_: 19 times
and needed for sort and search 20 msec
not sure it’s what you need