hash-sets: faster intersect and diff, when both are hash-sets.

db4
John Benediktsson 2013-03-26 16:24:45 -07:00
parent ac8473e0ea
commit daaf090459
1 changed files with 11 additions and 5 deletions

View File

@ -149,7 +149,11 @@ INSTANCE: hash-set set
PRIVATE>
M: hash-set intersect (intersect) >hash-set ;
M: hash-set intersect
over hash-set? [
small/large array/tester not-tombstones
filter >hash-set
] [ (intersect) >hash-set ] if ;
M: hash-set intersects?
over hash-set? [
@ -160,11 +164,13 @@ M: hash-set union
over hash-set? [
small/large [ array>> ] [ clone ] bi*
[ [ adjoin ] curry each-member ] keep
] [
(union) >hash-set
] if ;
] [ (union) >hash-set ] if ;
M: hash-set diff (diff) >hash-set ;
M: hash-set diff
over hash-set? [
array/tester [ not ] compose not-tombstones
filter >hash-set
] [ (diff) >hash-set ] if ;
M: hash-set subset?
over hash-set? [