++ed by:

1 non-PAUSE user.

Mirkos Vladislav
and 1 contributors

NAME

Hash::Iterator - Hashtable Iterator.

SYNOPSIS

    my $iterator = Hash::Iterator->new( map { $_ => uc $_ } 'a'..'z' );

    while ($iterator->next) {
        say sprintf("%s => %s", $iterator->peek_key, $iterator->peek_value);
    }

    my $iterator = Hash::Iterator->new( a => [qw(one two three)] );
    $iterator->next;

    if ( $iterator->is_ref('ARRAY') ) {
        foreach my $item ( @{$iterator->peek_value} ) {
            say $item;
        }
    }

DESCRIPTION

CONSTRUCTORS

new

    my $iterator = Hash::Iterator->new( %hash );

Return a Hash::Iterator for hash

METHODS

next

    $iterator->next;

Advance the iterator to the next key-value pair

previous

    $iterator->previous;

Advance the iterator to the previous key-value pair

done

    do {
        ....
    } while ($iterator->done);

Returns a boolean value if the iterator was exhausted

peek_key

    say $iterator->peek_key;

Return the key of the current key-value pair. It's not allowed to call this method before next() was called for the first time or after the iterator was exhausted.

peek_value

    say $iterator->peek_value;

Return the value of the current key-value pair. It's not allowed to call this method before next() was called for the first time or after the iterator was exhausted.

is_ref

    if ( $iterator->is_ref('ARRAY') ) {
        ...
    }

Returns a boolean value if value is a reference.

get_keys

    my @keys =  $iterator->get_keys;

Returns a list of all keys from hash

AUTHOR

vlad mirkos, <vladmirkos@sd.apple.com>

COPYRIGHT AND LICENSE

Copyright (C) 2017 by vlad mirkos

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.18.2 or, at your option, any later version of Perl 5 you may have available.