Skip to content
Permalink
Browse files

Add R:I.ITERATIONSET2LISTITER method

Takes an IterationSet type / object and returns a nqp::list iterator for
its keys.  To be used in SetHash/BagHash/MixHash iterators.
  • Loading branch information...
lizmat committed Mar 21, 2019
1 parent 9399ea1 commit a6a607054a784a14573155ea726fe3b4db337974
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/core/Rakudo/Internals.pm6
@@ -1681,6 +1681,21 @@ implementation detail and has no serviceable parts inside"
what.^set_name(base.^name ~ '[' ~ type.^name ~ ']');
what
}

# Return a nqp list iterator from an IterationSet
proto method ITERATIONSET2LISTITER(|) {*}
multi method ITERATIONSET2LISTITER(IterationSet:U) {
nqp::iterator(nqp::list_s)
}
multi method ITERATIONSET2LISTITER(IterationSet:D \iterationset) {
my $iter := nqp::iterator(iterationset);
my $keys := nqp::list_s;
nqp::while(
$iter,
nqp::push_s($keys,nqp::iterkey_s(nqp::shift($iter)))
);
nqp::iterator($keys)
}
}

# expose the number of bits a native int has

0 comments on commit a6a6070

Please sign in to comment.
You can’t perform that action at this time.