Subversion Repositories DevTools

Rev

Rev 317 | Rev 4362 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 317 Rev 3987
Line 8... Line 8...
8
# Environment(s): jats
8
# Environment(s): jats
9
#
9
#
10
# Description   : This package contains functions to manipulate arrays
10
# Description   : This package contains functions to manipulate arrays
11
#                 and hashes
11
#                 and hashes
12
#
12
#
-
 
13
#                   HashJoin            Join array of args to a Hash
-
 
14
#                   HashUniqueJoin      Join New items from array of args to a Hash
-
 
15
#                   UniquePush          Push items unless already in array
-
 
16
#                   ArrayDelete         Delete ietms from array
-
 
17
#                   ArrayList           Convert a list of scalars and/or array
-
 
18
#                                       references to array
13
#
-
 
14
#......................................................................#
19
#......................................................................#
15
 
20
 
16
 
21
 
17
################################################################################
22
################################################################################
18
#   Global variables used by functions in this package
23
#   Global variables used by functions in this package
Line 32... Line 37...
32
our @EXPORT = qw(
37
our @EXPORT = qw(
33
            HashJoin
38
            HashJoin
34
            HashUniqueJoin
39
            HashUniqueJoin
35
            UniquePush
40
            UniquePush
36
            ArrayList
41
            ArrayList
-
 
42
            ArrayDelete
37
            );
43
            );
38
 
44
 
39
#-------------------------------------------------------------------------------
45
#-------------------------------------------------------------------------------
40
# Function        : HashJoin
46
# Function        : HashJoin
41
#
47
#
Line 147... Line 153...
147
        }
153
        }
148
    }
154
    }
149
    return ($ret);
155
    return ($ret);
150
}
156
}
151
 
157
 
-
 
158
#-------------------------------------------------------------------------------
-
 
159
# Function        : ArrayDelete
-
 
160
#
-
 
161
# Description     : Delete items from an array
-
 
162
#
-
 
163
# Inputs          : $pArray             - Ref to an array
-
 
164
#                   @arguments          - Arguments to process
-
 
165
#
-
 
166
# Returns         : Number of items that were removed
-
 
167
#
-
 
168
 
-
 
169
sub ArrayDelete
-
 
170
{
-
 
171
    my( $pArray, @arguments ) = @_;
-
 
172
    my( $ret ) = 0;
-
 
173
    my %deleteMe = map { $_ => 1 } @arguments;
-
 
174
    my @array;
-
 
175
 
-
 
176
    foreach ( @$pArray )
-
 
177
    {
-
 
178
        unless ( exists $deleteMe{$_} )
-
 
179
        {
-
 
180
            push @array, $_;
-
 
181
            $ret++;
-
 
182
        }
-
 
183
    }
-
 
184
    @$pArray = @array;
-
 
185
    return ($ret);
-
 
186
}
-
 
187
 
-
 
188
 
152
 
189
 
153
#-------------------------------------------------------------------------------
190
#-------------------------------------------------------------------------------
154
# Function        : ArrayList
191
# Function        : ArrayList
155
#
192
#
156
# Description     : Convert a list of scalars and/or array references
193
# Description     : Convert a list of scalars and/or array references