0
|
1 NAME
|
|
2 PseudoHeap
|
|
3
|
|
4 SYNOPSIS
|
|
5 use PseudoHeap;
|
|
6
|
|
7 use PseudoHeap qw(:all);
|
|
8
|
|
9 DESCRIPTION
|
|
10 PseudoHeap class provides the following methods:
|
|
11
|
|
12 new, AddKeyValuePair, AddKeyValuePairs, DeleteKey, DeleteKeys,
|
|
13 DeleteMaxKey, DeleteMinKey, GetCurrentSize, GetKeyType, GetKeyValues,
|
|
14 GetKeys, GetMaxKey, GetMaxSize, GetMinKey, GetSortedKeys, GetType,
|
|
15 SetKeyType, SetMaxSize, SetType, StringifyPseudoHeap
|
|
16
|
|
17 PseudoHeap is designed to support tracking of a specific number of
|
|
18 largest or smallest key/value pairs with numeric or alphanumeric keys
|
|
19 along with corresponding scalar or reference values.
|
|
20
|
|
21 Although PseudoHeap is conceptually similar to a heap, it lacks number
|
|
22 of key properties of a traditional heap data structure: no concept of
|
|
23 root, parent and child nodes; no ordering of keys in any particular
|
|
24 order; no specific location greatest or smallest key.
|
|
25
|
|
26 The keys are simply stored in a hash with each key pointing to an array
|
|
27 containing specified values. The min/max keys are updated during
|
|
28 addition and deletion of key/value pairs; these can be retrieved by
|
|
29 accessing corresponding hash.
|
|
30
|
|
31 Addition and deletion of key/value is also straightforward using hashes.
|
|
32 However, min/max keys need to be identified which is done using Perl
|
|
33 sort function on the keys.
|
|
34
|
|
35 FUNCTIONS
|
|
36 new
|
|
37 $NewPseudoHeap = new PseudoHeap(%NamesAndValues);
|
|
38
|
|
39 Using specified parameters *NamesAndValues* names and values hash,
|
|
40 new method creates a new object and returns a reference to a newly
|
|
41 created NewPseudoHeap object. By default, the following property
|
|
42 names are initialized:
|
|
43
|
|
44 Type = undef;
|
|
45 KeyType = undef;
|
|
46 MaxSize = 10;
|
|
47
|
|
48 Examples:
|
|
49
|
|
50 $NewPseudoHeap = new PseudoHeap(
|
|
51 'Type' => 'KeepTopN',
|
|
52 'KeyType' => 'Numeric');
|
|
53
|
|
54 $NewPseudoHeap = new PseudoHeap(
|
|
55 'Type' => 'KeepTopN',
|
|
56 'KeyType' => 'AlphaNumeric',
|
|
57 'MaxSize' => '20');
|
|
58
|
|
59 $NewPseudoHeap = new PseudoHeap(
|
|
60 'Type' => 'KeepBottomN',
|
|
61 'KeyType' => 'AlphaNumeric',
|
|
62 'MaxSize' => '20');
|
|
63
|
|
64 AddKeyValuePair
|
|
65 $PseudoHeap->AddKeyValuePair($Key, $Value);
|
|
66
|
|
67 Add specified *Key* and *Value* pair to pseudo heap using a new or
|
|
68 an existing key and returns PseudoHeap.
|
|
69
|
|
70 AddKeyValuePairs
|
|
71 $PseudoHeap->AddKeyValuePairs(@KeyValuePairs);
|
|
72
|
|
73 Adds multiple key and value pairs specified in array *KeyValuePairs*
|
|
74 to pseudo heap using a new or existing keys and returns PseudoHeap.
|
|
75
|
|
76 DeleteKey
|
|
77 $PseudoHeap->DeleteKey($Key);
|
|
78
|
|
79 Deletes a specified *Key* from pseudo heap and returns PseudoHeap.
|
|
80
|
|
81 DeleteKeys
|
|
82 $PseudoHeap->DeleteKeys(@Keys);
|
|
83
|
|
84 Deletes a specified *Keys* from pseudo heap and returns PseudoHeap.
|
|
85
|
|
86 DeleteMaxKey
|
|
87 $PseudoHeap->DeleteMaxKey();
|
|
88
|
|
89 Deletes a *MaxKey* along with its associated values from pseudo heap
|
|
90 and returns PseudoHeap.
|
|
91
|
|
92 DeleteMinKey
|
|
93 $PseudoHeap->DeleteMinKey();
|
|
94
|
|
95 Deletes a *MinKey* along with its associated values from pseudo heap
|
|
96 and returns PseudoHeap.
|
|
97
|
|
98 GetCurrentSize
|
|
99 $Size = $PseudoHeap->GetCurrentSize();
|
|
100
|
|
101 Returns current *Size* of pseudo heap corresponding to number to
|
|
102 keys in heap.
|
|
103
|
|
104 GetKeyType
|
|
105 $KeyType = $PseudoHeap->GetKeyType();
|
|
106
|
|
107 Returns *KeyType* of pseudo heap. Possible KeyType values: *Numeric
|
|
108 or Alphanumeric*.
|
|
109
|
|
110 GetKeyValues
|
|
111 @Values = $PseudoHeap->GetKeyValues($Key);
|
|
112 $NumOfValues = $PseudoHeap->GetKeyValues($Key);
|
|
113
|
|
114 Returns an array containing Values associated with a specified *Key*
|
|
115 in pseudo heap. In scalar context, it returns number of values
|
|
116 associated with a key.
|
|
117
|
|
118 GetKeys
|
|
119 @Keys = $PseudoHeap->GetKeys();
|
|
120 $NumOfKeys = $PseudoHeap->GetKeys();
|
|
121
|
|
122 Returns an array containing all Keys in pseudo heap. In scalar
|
|
123 context, it returns total number of keys.
|
|
124
|
|
125 GetMaxKey
|
|
126 $MaxKey = $PseudoHeap->GetMaxKey();
|
|
127
|
|
128 Returns *MaxKey* present in pseudo heap.
|
|
129
|
|
130 GetMaxSize
|
|
131 $MaxSize = $PseudoHeap->GetMaxSize();
|
|
132
|
|
133 Returns *MaxSize* of pseudo heap.
|
|
134
|
|
135 GetMinKey
|
|
136 $MinKey = $PseudoHeap->GetMinKey();
|
|
137
|
|
138 Returns *MinKey* present in pseudo heap.
|
|
139
|
|
140 GetSortedKeys
|
|
141 @Keys = $PseudoHeap->GetSortedKeys();
|
|
142 $NumOfKeys = $PseudoHeap->GetSortedKeys();
|
|
143
|
|
144 Returns an array containing all sorted Keys in pseudo heap. In
|
|
145 scalar context, it retruns total number of keys.
|
|
146
|
|
147 Keys are sorted based on values of Type and KeyType for pseudo heap:
|
|
148
|
|
149 Type KeyType SortOrder SortOperator
|
|
150 KeepTopN Numeric Descending <=>
|
|
151 KeepTopN Alphanumeric Descending cmp
|
|
152 KeepBottomN Numeric Ascending <=>
|
|
153 KeepBottomN Alphanumeric Ascending cmp
|
|
154
|
|
155 GetType
|
|
156 $Type = $PseudoHeap->GetType();
|
|
157
|
|
158 Returns *Type* of pseudo heap.
|
|
159
|
|
160 SetKeyType
|
|
161 $PseudoHeap->SetKeyType($KeyType);
|
|
162
|
|
163 Sets *KeyType* of pseudo heap and returns PseudoHeap.
|
|
164
|
|
165 SetMaxSize
|
|
166 $PseudoHeap->SetMaxSize($MaxSize);
|
|
167
|
|
168 Sets *MaxSize* of pseudo heap and returns PseudoHeap.
|
|
169
|
|
170 SetType
|
|
171 $PseudoHeap->SetType($Type);
|
|
172
|
|
173 Sets *Type* of pseudo heap and returns PseudoHeap.
|
|
174
|
|
175 StringifyPseudoHeap
|
|
176 $PseudoHeapString = $PseudoHeap->StringifyPseudoHeap();
|
|
177
|
|
178 Returns a string containing information about *PseudoHeap* object
|
|
179
|
|
180 AUTHOR
|
|
181 Manish Sud <msud@san.rr.com>
|
|
182
|
|
183 COPYRIGHT
|
|
184 Copyright (C) 2015 Manish Sud. All rights reserved.
|
|
185
|
|
186 This file is part of MayaChemTools.
|
|
187
|
|
188 MayaChemTools is free software; you can redistribute it and/or modify it
|
|
189 under the terms of the GNU Lesser General Public License as published by
|
|
190 the Free Software Foundation; either version 3 of the License, or (at
|
|
191 your option) any later version.
|
|
192
|