package Moose::Autobox::Hash;
use Moose::Role 'with';
-our $VERSION = '0.09';
+our $VERSION = '0.13';
with 'Moose::Autobox::Ref',
'Moose::Autobox::Indexed';
sub slice {
my ($hash, $keys) = @_;
return [ @{$hash}{@$keys} ];
-};
+}
+
+sub each {
+ my ($hash, $sub) = @_;
+ for my $key (CORE::keys %$hash) {
+ $sub->($key, $hash->{$key});
+ }
+}
+
+sub each_key {
+ my ($hash, $sub) = @_;
+ $sub->($_) for CORE::keys %$hash;
+}
+
+sub each_value {
+ my ($hash, $sub) = @_;
+ $sub->($_) for CORE::values %$hash;
+}
+
+sub each_n_values {
+ my ($hash, $n, $sub) = @_;
+ my @keys = CORE::keys %$hash;
+ my $it = List::MoreUtils::natatime($n, @keys);
+
+ while (my @vals = $it->()) {
+ $sub->(@$hash{ @vals });
+ }
+
+ return;
+}
+
+
+# End Indexed
sub print { CORE::print %{$_[0]} }
sub say { CORE::print %{$_[0]}, "\n" }
=item B<slice>
+=item B<each>
+
+=item B<each_key>
+
+=item B<each_value>
+
+=item B<each_n_values>
+
=back
=over 4