line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::List; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::List.pm |
11
|
|
|
|
|
|
|
# Description: Utility functions for handling lists |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 27/01/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 27/01/2005 Initially needed a way to split lists |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
############################################################################### |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
290
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
############################################################################### |
24
|
|
|
|
|
|
|
# |
25
|
|
|
|
|
|
|
# get_unique - return a sorted unique list |
26
|
|
|
|
|
|
|
# |
27
|
|
|
|
|
|
|
############################################################################### |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub get_unique { |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
1
|
|
my (@list) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $seen; |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
foreach my $member (@list) { |
36
|
0
|
|
|
|
|
|
$seen->{$member} = 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
return sort { $a cmp $b } keys %$seen; |
|
0
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
############################################################################### |
45
|
|
|
|
|
|
|
# |
46
|
|
|
|
|
|
|
# halve_list - split a list in two |
47
|
|
|
|
|
|
|
# |
48
|
|
|
|
|
|
|
############################################################################### |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub halve_list { |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
0
|
1
|
|
my (@list) = @_; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $halfway = scalar(@list)/2; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my @list1; |
57
|
|
|
|
|
|
|
my @list2; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
for (my $i = 0; $i <= $#list; $i++) { |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
if ($i >= $halfway) { |
62
|
0
|
|
|
|
|
|
push(@list2, $list[$i]); |
63
|
|
|
|
|
|
|
} else { |
64
|
0
|
|
|
|
|
|
push(@list1, $list[$i]); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
return (\@list1, \@list2); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
############################################################################### |
74
|
|
|
|
|
|
|
# |
75
|
|
|
|
|
|
|
# quarter_list - split a list in four! |
76
|
|
|
|
|
|
|
# |
77
|
|
|
|
|
|
|
############################################################################### |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub quarter_list { |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
0
|
1
|
|
my (@list) = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my ($a, $b) = halve_list(@list); |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
my ($list1, $list2) = halve_list(@$a); |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my ($list3, $list4) = halve_list(@$b); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return ($list1, $list2, $list3, $list4); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Goo::List - Utility functions for handling lists |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SYNOPSIS |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
use Goo::List; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 DESCRIPTION |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 METHODS |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item get_unique |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return a sorted unique list |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item halve_list |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
return a list split in two |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item quarter_list |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return a list split in four |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SEE ALSO |
132
|
|
|
|
|
|
|
|