summaryrefslogtreecommitdiff
path: root/fml/lib/File
diff options
context:
space:
mode:
authorfukachan <fukachan>2002-01-27 08:28:11 +0000
committerfukachan <fukachan>2002-01-27 08:28:11 +0000
commitcb48a5148755196017b60a78c9433bfaf1d6df32 (patch)
treefba991843135a314c8b9a00281d1a0540c01497f /fml/lib/File
parent6c7aeb9cc77c5d047a7cec184e52a56c3d9770a5 (diff)
downloadfml8-cb48a5148755196017b60a78c9433bfaf1d6df32.tar.gz
fml8-cb48a5148755196017b60a78c9433bfaf1d6df32.tar.bz2
fml8-cb48a5148755196017b60a78c9433bfaf1d6df32.zip
search_max_id() searches all keys if full_search option specified
Diffstat (limited to 'fml/lib/File')
-rw-r--r--fml/lib/File/Sequence.pm39
1 files changed, 38 insertions, 1 deletions
diff --git a/fml/lib/File/Sequence.pm b/fml/lib/File/Sequence.pm
index 2f8df52c..656f63e7 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.15 2002/01/13 06:59:50 fukachan Exp $
+# $FML: Sequence.pm,v 1.16 2002/01/13 13:35:25 fukachan Exp $
#
package File::Sequence;
@@ -194,6 +194,13 @@ To search max_id in hash key,
$self->search_max_id( { hash => \%hash_table });
+to search max_id among all keys,
+
+ $self->search_max_id( {
+ hash => \%hash_table,
+ full_search => 1,
+ });
+
=cut
@@ -204,6 +211,36 @@ To search max_id in hash key,
sub search_max_id
{
my ($self, $args) = @_;
+
+ # full search
+ if (defined $args->{ hash } && defined $args->{ full_search } ) {
+ my $hash = $args->{ hash };
+ my $max = 0;
+
+ my ($k, $v);
+ while ( ($k, $v) = each %$hash) {
+ $max = $max > $k ? $max : $k;
+ }
+
+ return $max;
+ }
+ # old style, search max from bottom (e.g. 0 or 1)
+ elsif (defined $args->{ hash }) {
+ $self->_search_max_id_from_bottom($args);
+ }
+ else {
+ warn("no argument");
+ }
+}
+
+
+# Descriptions: search max id number from bottom
+# Arguments: OBJ($self) HASH_REF($args)
+# Side Effects: none
+# Return Value: NUM
+sub _search_max_id_from_bottom
+{
+ my ($self, $args) = @_;
my ($pebot, $k, $v);
my $unit = 50;