Skip to content

Commit 35cd2c7

Browse files
committed
testOk
1 parent 1fe84af commit 35cd2c7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

algo/lru.pl

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use strict;
22
use warnings;
33

4+
use Data::Dumper;
5+
46
sub newList {
57
return { N => 0, First => undef, Last => undef };
68
}
@@ -67,7 +69,7 @@ sub delLRU {
6769
my $node = $$ref{Hash}->{$k};
6870
if ($node) {
6971
&removeLink($$ref{Link}, $node);
70-
delete $$ref{Hash}{$k};
72+
delete $$ref{Hash}->{$k};
7173
}
7274
}
7375
}
@@ -96,16 +98,13 @@ sub Get {
9698
my $max = 5;
9799
my $l = &NewLRU($max);
98100

99-
for (my $i = 0; $i < $max*2; $i++) {
101+
for (my $i = 0; $i < $max*10; $i++) {
100102
&Add($l, "Data$i");
101103
}
102104
&Dump($l);
103105

104-
my $data;
105-
106-
do {
107-
$data = &Get($l);
108-
print "$data\n" if $data;
109-
} while ($data);
106+
for (my $i = 0; $i < $max-1; $i++) {
107+
print &Get($l)."\n";
108+
}
110109

111-
&Dump($l);
110+
print Dumper($l);

0 commit comments

Comments
 (0)