From 773026b2df55ca5a76779ca4e240ebed71bbfaac Mon Sep 17 00:00:00 2001 From: fukachan Date: Tue, 20 Nov 2001 06:59:00 +0000 Subject: implement search_max_id() in hash key --- fml/lib/File/Sequence.pm | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'fml/lib/File') diff --git a/fml/lib/File/Sequence.pm b/fml/lib/File/Sequence.pm index 1a5261bc..f252edc4 100644 --- a/fml/lib/File/Sequence.pm +++ b/fml/lib/File/Sequence.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Sequence.pm,v 1.8 2001/05/27 14:27:55 fukachan Exp $ +# $FML: Sequence.pm,v 1.9 2001/10/17 03:05:58 fukachan Exp $ # package File::Sequence; @@ -186,6 +186,45 @@ sub get_id } +=head2 search_max_id($args) + +To search max_id in hash key, + + $self->search_max_id( { hash => \%hash_table }); + +=cut + + +# Descriptions: search max id number +# Arguments: $self $args +# Side Effects: none +# Return Value: number +sub search_max_id +{ + my ($self, $args) = @_; + my ($pebot, $k, $v); + my $unit = 50; + + if (defined $args->{ hash }) { + my $hash = $args->{ hash }; + ($pebot, $v) = each %$hash; + + PEBOT_SEARCH: + while (1) { + last PEBOT_SEARCH unless defined $hash->{ $pebot + $unit }; + $pebot += $unit; + } + + # increment by 1. + do { + $pebot++; + } while (defined $hash->{ $pebot + 1 }); + + return $pebot; + } +} + + =head1 AUTHOR Ken'ichi Fukamachi -- cgit v1.2.1