... |
... |
@@ -770,15 +770,16 @@ |
770
|
770
|
(return (values length list2))))))
|
771
|
771
|
(when (< len 15)
|
772
|
772
|
(return-from list-to-hashtable (values nil nil)))
|
773
|
|
- (flet ((build-hash (len list)
|
774
|
|
- (let ((hashtable (make-hash-table :test test :size len)))
|
775
|
|
- (dolist (item list)
|
776
|
|
- (setf (gethash (apply-key key item) hashtable) item))
|
777
|
|
- hashtable)))
|
778
|
|
- (cond ((eq shorter-list list2)
|
779
|
|
- (values (build-hash len list2) list2))
|
780
|
|
- ((eq shorter-list list1)
|
781
|
|
- (values (build-hash len list1) list1))))))))
|
|
773
|
+ (cond ((eq shorter-list list2)
|
|
774
|
+ (let ((hashtable (make-hash-table :test test :size len)))
|
|
775
|
+ (dolist (item list2)
|
|
776
|
+ (setf (gethash (apply-key key item) hashtable) item))
|
|
777
|
+ (values hashtable list2)))
|
|
778
|
+ ((eq shorter-list list1)
|
|
779
|
+ (let ((hashtable (make-hash-table :test test :size len)))
|
|
780
|
+ (dolist (item list1)
|
|
781
|
+ (push item (gethash (apply-key key item) hashtable)))
|
|
782
|
+ (values hashtable list1))))))))
|
782
|
783
|
|
783
|
784
|
;;; UNION -- Public.
|
784
|
785
|
;;;
|
... |
... |
@@ -870,14 +871,17 @@ |
870
|
871
|
(dolist (item list1)
|
871
|
872
|
(unless (gethash (apply-key key item) hashtable)
|
872
|
873
|
(push item diff)))
|
873
|
|
- diff))
|
|
874
|
+ (nreverse diff)))
|
874
|
875
|
((eq shorter-list list1)
|
875
|
876
|
;; list1 was placed in the hash table.
|
876
|
877
|
(dolist (item list2)
|
877
|
|
- (when (gethash (apply-key key item) hashtable)
|
|
878
|
+ (unless (eq hashtable (gethash (apply-key key item) hashtable hashtable))
|
878
|
879
|
(remhash item hashtable)))
|
879
|
|
- (loop for item being the hash-values of hashtable
|
880
|
|
- collect item)))))
|
|
880
|
+ (let ((result '()))
|
|
881
|
+ (maphash #'(lambda (key value)
|
|
882
|
+ (declare (ignore key))
|
|
883
|
+ (setq result (nconc result value)))
|
|
884
|
+ hashtable))))))
|
881
|
885
|
|
882
|
886
|
|
883
|
887
|
(defun nset-difference (list1 list2 &key key
|