I have a list of words and I want to test input to determine if it is a word included in the word list.
My first thought was to use NSSet; with 100000 words however, it started to show it's limitations. It's for the iPhone, and I'd really like to do several lookups, without a perceivable delay.
I tried splitting the words into multiple NSSets, each containing a subset based on the length of the word, then I check in the corresponding. To my surprise, I found this to be a significant improvement. I was surprised because I'd always read that NSSet was best for lookups, and expected that the NSSet would make a similar comparison itself, except based on some kind of hash instead.
Short of implementing a tree or other custom structure, are there better ways that I could be performing this test?
My first thought was to use NSSet; with 100000 words however, it started to show it's limitations. It's for the iPhone, and I'd really like to do several lookups, without a perceivable delay.
I tried splitting the words into multiple NSSets, each containing a subset based on the length of the word, then I check in the corresponding. To my surprise, I found this to be a significant improvement. I was surprised because I'd always read that NSSet was best for lookups, and expected that the NSSet would make a similar comparison itself, except based on some kind of hash instead.
Short of implementing a tree or other custom structure, are there better ways that I could be performing this test?