hash-sets: faster intersect and diff, when both are hash-sets.
parent
ac8473e0ea
commit
daaf090459
|
@ -149,7 +149,11 @@ INSTANCE: hash-set set
|
||||||
|
|
||||||
PRIVATE>
|
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?
|
M: hash-set intersects?
|
||||||
over hash-set? [
|
over hash-set? [
|
||||||
|
@ -160,11 +164,13 @@ M: hash-set union
|
||||||
over hash-set? [
|
over hash-set? [
|
||||||
small/large [ array>> ] [ clone ] bi*
|
small/large [ array>> ] [ clone ] bi*
|
||||||
[ [ adjoin ] curry each-member ] keep
|
[ [ 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?
|
M: hash-set subset?
|
||||||
over hash-set? [
|
over hash-set? [
|
||||||
|
|
Loading…
Reference in New Issue