[elephant-cvs] CVS elephant/src/elephant

ieslick ieslick at common-lisp.net
Tue Feb 20 20:03:45 UTC 2007


Update of /project/elephant/cvsroot/elephant/src/elephant
In directory clnet:/tmp/cvs-serv26098/src/elephant

Modified Files:
	classindex.lisp collections.lisp 
Log Message:
Allow map-instances over string indices as well as numeric

--- /project/elephant/cvsroot/elephant/src/elephant/classindex.lisp	2007/02/20 19:12:58	1.19
+++ /project/elephant/cvsroot/elephant/src/elephant/classindex.lisp	2007/02/20 20:03:45	1.20
@@ -425,7 +425,7 @@
   (get-instances-by-range (find-class class) slot-name start end))
 
 (defmethod get-instances-by-range ((class persistent-metaclass) idx-name start end)
-  (declare (type fixnum start end)
+  (declare (type (or fixnum null) start end)
 	   (type string idx-name))
   (let ((instances nil))
     (declare (type list instances))
--- /project/elephant/cvsroot/elephant/src/elephant/collections.lisp	2007/02/20 19:12:58	1.10
+++ /project/elephant/cvsroot/elephant/src/elephant/collections.lisp	2007/02/20 20:03:45	1.11
@@ -337,6 +337,12 @@
 	   (unless more (return nil))
 	   (funcall fn k v))))))
 
+(defun lisp-compare<= (a b)
+  (etypecase a
+    (number (<= a b))
+    (string (string<= a b))
+    (persistent (<= (oid a) (oid b)))))
+
 (defmethod map-index (fn (index btree-index) &rest args &key start end)
   "Like map-btree, but takes a function of three arguments key, value and primary key
    if you want to get at the primary key value, otherwise use map-btree"
@@ -347,7 +353,7 @@
 	(labels ((next-range ()
 		   (multiple-value-bind (exists? skey val pkey) (cursor-pnext-nodup cur)
 		     (if (or (and exists? (not end))
-			     (and exists? (<= skey end)))
+			     (and exists? (lisp-compare<= skey end)))
 		       (progn
 			 (funcall fn skey val pkey)
 			 (next-in-range skey))
@@ -367,7 +373,7 @@
 		  (cursor-pset-range cur start)
 		  (cursor-pfirst cur))
 	    (if (or (and exists? (not end))
-		    (and exists? (<= skey end)))
+		    (and exists? (lisp-compare<= skey end)))
 		(progn
 		  (funcall fn skey val pkey)
 		  (next-in-range skey))




More information about the Elephant-cvs mailing list