hash-sets: slightly faster filter-members.
parent
daaf090459
commit
1f13eefad2
|
@ -147,12 +147,18 @@ INSTANCE: hash-set set
|
||||||
: array/tester ( hash-set1 hash-set2 -- array quot )
|
: array/tester ( hash-set1 hash-set2 -- array quot )
|
||||||
[ array>> ] dip [ in? ] curry ; inline
|
[ array>> ] dip [ in? ] curry ; inline
|
||||||
|
|
||||||
|
: filter-members ( hash-set array quot: ( elt -- ? ) -- accum )
|
||||||
|
[ dup ] prepose rot cardinality <vector> [
|
||||||
|
[ push-unsafe ] curry [ [ drop ] if ] curry
|
||||||
|
compose each
|
||||||
|
] keep ; inline
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
M: hash-set intersect
|
M: hash-set intersect
|
||||||
over hash-set? [
|
over hash-set? [
|
||||||
small/large array/tester not-tombstones
|
small/large dupd array/tester not-tombstones
|
||||||
filter >hash-set
|
filter-members >hash-set
|
||||||
] [ (intersect) >hash-set ] if ;
|
] [ (intersect) >hash-set ] if ;
|
||||||
|
|
||||||
M: hash-set intersects?
|
M: hash-set intersects?
|
||||||
|
@ -168,8 +174,8 @@ M: hash-set union
|
||||||
|
|
||||||
M: hash-set diff
|
M: hash-set diff
|
||||||
over hash-set? [
|
over hash-set? [
|
||||||
array/tester [ not ] compose not-tombstones
|
dupd array/tester [ not ] compose not-tombstones
|
||||||
filter >hash-set
|
filter-members >hash-set
|
||||||
] [ (diff) >hash-set ] if ;
|
] [ (diff) >hash-set ] if ;
|
||||||
|
|
||||||
M: hash-set subset?
|
M: hash-set subset?
|
||||||
|
|
Loading…
Reference in New Issue