]> gitweb.factorcode.org Git - factor.git/commitdiff
hash-sets: speed up diff, intersect, and union.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Apr 2012 17:58:08 +0000 (10:58 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 16 Apr 2012 17:58:08 +0000 (10:58 -0700)
core/hash-sets/hash-sets.factor

index 1ed514c3f25b412e4723a4271cdb0b3ad285778b..6e624dec708d5e22fa2279bc904e49c5b11bad77 100644 (file)
@@ -1,6 +1,6 @@
 ! Copyright (C) 2010 Daniel Ehrenberg
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs hashtables kernel sets
+USING: accessors assocs hashtables kernel sets sets.private
 sequences parser ;
 
 IN: hash-sets
@@ -23,6 +23,9 @@ M: hash-set set-like drop dup hash-set? [ members >hash-set ] unless ;
 M: hash-set clone table>> clone hash-set boa ;
 M: hash-set null? table>> assoc-empty? ;
 M: hash-set cardinality table>> assoc-size ;
+M: hash-set intersect small/large sequence/tester filter >hash-set ;
+M: hash-set union [ members ] bi@ append >hash-set ;
+M: hash-set diff sequence/tester [ not ] compose filter >hash-set ;
 
 M: sequence fast-set >hash-set ;
 M: f fast-set drop H{ } clone hash-set boa ;