[elephant-devel] Querying for objects on two slots
Leslie P. Polzer
sky at viridian-project.de
Tue Jan 6 08:35:42 UTC 2009
On Mon, Jan 05, 2009 at 10:36:29PM -0800, Yarek Kowalik wrote:
> I've run into several situations where I want to query for objects that
> match values two or more slots. I currently do something like this:
>
> (defclass my-class ()
> ((a :accessor slot-a)
> (b :accessor slot-b
> :index b))
> (:documentation "my test class"))
>
> (find-if (lambda (obj)
> (equal (slot-a obj) val-a))
> (elephant:get-instances-by-value 'my-class 'slot-b val-b))
>
>
> Is this a reasonable way of finding an object of type 'my-class that matches
> on values val-a and val-b for slots a and b?
Use MAP-CLASS, this will considerably speed up the query.
More information about the elephant-devel
mailing list