]> gitweb.factorcode.org Git - factor.git/commitdiff
hash-sets: faster intersects?.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 26 Mar 2013 23:00:31 +0000 (16:00 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 27 Mar 2013 00:42:40 +0000 (17:42 -0700)
core/hash-sets/hash-sets.factor

index 9c8d4fbfe9dca04b9568cb9563ccbfc3e841e797..e192944c1c7eeb06e4028d296376934e00755fef 100644 (file)
@@ -138,6 +138,12 @@ INSTANCE: hash-set set
 
 M: hash-set intersect (intersect) >hash-set ;
 
+M: hash-set intersects?
+    over hash-set? [
+        small/large [ array>> ] dip [ in? ] curry
+        [ if ] curry [ dup tombstone? [ drop t ] ] prepose any?
+    ] [ small/large sequence/tester any? ] if ;
+
 M: hash-set union
     over hash-set? [
         small/large [ array>> ] [ clone ] bi*