Skip to content

Commit

Permalink
Introduce MappyIterator-values class
Browse files Browse the repository at this point in the history
General purpose iterator class that returns the values of a hash.
To be used in Map, Baggy and typed hashes.
  • Loading branch information
lizmat committed Aug 14, 2016
1 parent 191dc0a commit 6d97bad
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/Rakudo/Internals.pm
Expand Up @@ -31,6 +31,20 @@ my class Rakudo::Internals {
method sink-all(--> IterationEnd) { $!iter := Mu }
}

our class MappyIterator-values does MappyIterator {
method pull-one() is raw {
$!iter
?? nqp::iterval(nqp::shift($!iter))
!! IterationEnd
}
method push-all($target --> IterationEnd) {
nqp::while( # doesn't sink
$!iter,
$target.push(nqp::iterval(nqp::shift($!iter)))
)
}
}

our role BlobbyIterator does Iterator {
has $!blob;
has int $!elems;
Expand Down

0 comments on commit 6d97bad

Please sign in to comment.