[Glass] How to find a string in a large number of strings ...
Martin McClure via Glass
glass at lists.gemtalksystems.com
Sat Mar 19 09:49:58 PDT 2016
On 03/19/2016 12:11 AM, itlists at schrievkrom.de wrote:
> Am 18.03.2016 um 23:31 schrieb Martin McClure:
>
>>
>> If it is the entire string, (the string is 'foobar' and I know I want
>> 'foobar') use a Set, this will be very efficient (but if you know the
>> entire string, why do you need to look it up at all?)
>
> The information is: is the string present within that set ... thats
> all. I think I will start with a set - though I thought its a waste of
> memory to have the whole stuff loaded into the gem memory and set
> operations are memory based ...
>
It sounds like a Set is ideal, then.
Memory should not be a problem when doing lookups, even with very large
sets. When doing a lookup, first the hash of the string to be looked up
is calculated. This indicates where in the set the string will be, if it
is present. Then only a small portion of the set, including that
position, is faulted into memory and the lookup completed. The entire
set does not ever need to be in memory at once.
Regards,
-Martin
More information about the Glass
mailing list