> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> Joel Neely
> Sent: Thursday, December 13, 2001 2:16 PM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Re: Searching objects

> I'm sure someone can polish this, but how about setting up the
> objects explicitly to be searchable on whatever criteria you
> have in mind?  Quick-and-dirty sample follows:

Hi, nice idea to make it generic on each data-field :-)).

> phones-by-name: func [name [string!]] [
>     foreach chum blackbook [
>         if find chum/get-searchable-fields name [
>             return chum/phones
>         ]
>     ]
>     return copy []
> ]

This solution uses a loop too. If possible I would like to avoid looing through
the objects.

I had something like using indices in mind. With this I would have something
like this:

myobjects: make hash! [] ; using index,object pairs
        = [1 obj1 2 obj2]

myobjects_names: make hash! [] ; using data-field, index pairs
        = ["robert" 1 "carl" 2 "joachim" 3]

Searching the object with a name joachim would result in object ID 3, than
makeing a lookup in the objects and get the object with ID 3. I hope you know
what I mean.

With this you will have an index for each data-field you want to search for.
Remembers me on the good old databases ;-)) Robert

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to