Skip to content

mirkos-vf/Hash-Iterator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hash-Iterator version 0.02

INSTALLATION

To install this module type the following:

	perl Makefile.PL
	make
	make test
	make install

cpan

	perl -MCPAN -e shell
	install Hash::Iterator

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 C

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 L<next()|/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 L<next()|/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, Evladmirkos@sd.apple.comE

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages