0
|
1 <html>
|
|
2 <head>
|
|
3 <title>MayaChemTools:Documentation:PseudoHeap.pm</title>
|
|
4 <meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
5 <link rel="stylesheet" type="text/css" href="../../css/MayaChemTools.css">
|
|
6 </head>
|
|
7 <body leftmargin="20" rightmargin="20" topmargin="10" bottommargin="10">
|
|
8 <br/>
|
|
9 <center>
|
|
10 <a href="http://www.mayachemtools.org" title="MayaChemTools Home"><img src="../../images/MayaChemToolsLogo.gif" border="0" alt="MayaChemTools"></a>
|
|
11 </center>
|
|
12 <br/>
|
|
13 <div class="DocNav">
|
|
14 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
15 <tr align="left" valign="top"><td width="33%" align="left"><a href="./PeriodicTable.html" title="PeriodicTable.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./SDFileUtil.html" title="SDFileUtil.html">Next</a></td><td width="34%" align="middle"><strong>PseudoHeap.pm</strong></td><td width="33%" align="right"><a href="././code/PseudoHeap.html" title="View source code">Code</a> | <a href="./../pdf/PseudoHeap.pdf" title="PDF US Letter Size">PDF</a> | <a href="./../pdfgreen/PseudoHeap.pdf" title="PDF US Letter Size with narrow margins: www.changethemargins.com">PDFGreen</a> | <a href="./../pdfa4/PseudoHeap.pdf" title="PDF A4 Size">PDFA4</a> | <a href="./../pdfa4green/PseudoHeap.pdf" title="PDF A4 Size with narrow margins: www.changethemargins.com">PDFA4Green</a></td></tr>
|
|
16 </table>
|
|
17 </div>
|
|
18 <p>
|
|
19 </p>
|
|
20 <h2>NAME</h2>
|
|
21 <p>PseudoHeap</p>
|
|
22 <p>
|
|
23 </p>
|
|
24 <h2>SYNOPSIS</h2>
|
|
25 <p>use PseudoHeap;</p>
|
|
26 <p>use PseudoHeap qw(:all);</p>
|
|
27 <p>
|
|
28 </p>
|
|
29 <h2>DESCRIPTION</h2>
|
|
30 <p><strong>PseudoHeap</strong> class provides the following methods:</p>
|
|
31 <p> <a href="#new">new</a>, <a href="#addkeyvaluepair">AddKeyValuePair</a>, <a href="#addkeyvaluepairs">AddKeyValuePairs</a>, <a href="#deletekey">DeleteKey</a>, <a href="#deletekeys">DeleteKeys</a>, <a href="#deletemaxkey">DeleteMaxKey</a>
|
|
32 , <a href="#deleteminkey">DeleteMinKey</a>, <a href="#getcurrentsize">GetCurrentSize</a>, <a href="#getkeytype">GetKeyType</a>, <a href="#getkeyvalues">GetKeyValues</a>, <a href="#getkeys">GetKeys</a>, <a href="#getmaxkey">GetMaxKey</a>
|
|
33 , <a href="#getmaxsize">GetMaxSize</a>, <a href="#getminkey">GetMinKey</a>, <a href="#getsortedkeys">GetSortedKeys</a>, <a href="#gettype">GetType</a>, <a href="#setkeytype">SetKeyType</a>, <a href="#setmaxsize">SetMaxSize</a>, <a href="#settype">SetType</a>
|
|
34 , <a href="#stringifypseudoheap">StringifyPseudoHeap</a>
|
|
35 </p><p>PseudoHeap is designed to support tracking of a specific number of largest or smallest key/value
|
|
36 pairs with numeric or alphanumeric keys along with corresponding scalar or reference values.</p>
|
|
37 <p>Although PseudoHeap is conceptually similar to a heap, it lacks number of key properties of a traditional
|
|
38 heap data structure: no concept of root, parent and child nodes; no ordering of keys in any particular
|
|
39 order; no specific location greatest or smallest key.</p>
|
|
40 <p>The keys are simply stored in a hash with each key pointing to an array containing specified values.
|
|
41 The min/max keys are updated during addition and deletion of key/value pairs; these can be retrieved
|
|
42 by accessing corresponding hash.</p>
|
|
43 <p>Addition and deletion of key/value is also straightforward using hashes. However, min/max keys
|
|
44 need to be identified which is done using Perl sort function on the keys.</p>
|
|
45 <p>
|
|
46 </p>
|
|
47 <h2>FUNCTIONS</h2>
|
|
48 <dl>
|
|
49 <dt><strong><a name="new" class="item"><strong>new</strong></a></strong></dt>
|
|
50 <dd>
|
|
51 <div class="OptionsBox">
|
|
52 $NewPseudoHeap = new PseudoHeap(%NamesAndValues);</div>
|
|
53 <p>Using specified parameters <em>NamesAndValues</em> names and values hash, <strong>new</strong> method creates
|
|
54 a new object and returns a reference to a newly created <strong>NewPseudoHeap</strong> object. By default,
|
|
55 the following property names are initialized:</p>
|
|
56 <div class="OptionsBox">
|
|
57 Type = undef;
|
|
58 <br/> KeyType = undef;
|
|
59 <br/> MaxSize = 10;</div>
|
|
60 <p>Examples:</p>
|
|
61 <div class="OptionsBox">
|
|
62 $NewPseudoHeap = new PseudoHeap(
|
|
63 'Type' => 'KeepTopN',
|
|
64 'KeyType' => 'Numeric');</div>
|
|
65 <div class="OptionsBox">
|
|
66 $NewPseudoHeap = new PseudoHeap(
|
|
67 'Type' => 'KeepTopN',
|
|
68 'KeyType' => 'AlphaNumeric',
|
|
69 'MaxSize' => '20');</div>
|
|
70 <div class="OptionsBox">
|
|
71 $NewPseudoHeap = new PseudoHeap(
|
|
72 'Type' => 'KeepBottomN',
|
|
73 'KeyType' => 'AlphaNumeric',
|
|
74 'MaxSize' => '20');</div>
|
|
75 </dd>
|
|
76 <dt><strong><a name="addkeyvaluepair" class="item"><strong>AddKeyValuePair</strong></a></strong></dt>
|
|
77 <dd>
|
|
78 <div class="OptionsBox">
|
|
79 $PseudoHeap->AddKeyValuePair($Key, $Value);</div>
|
|
80 <p>Add specified <em>Key</em> and <em>Value</em> pair to pseudo heap using a new or an existing
|
|
81 key and returns <strong>PseudoHeap</strong>.</p>
|
|
82 </dd>
|
|
83 <dt><strong><a name="addkeyvaluepairs" class="item"><strong>AddKeyValuePairs</strong></a></strong></dt>
|
|
84 <dd>
|
|
85 <div class="OptionsBox">
|
|
86 $PseudoHeap->AddKeyValuePairs(@KeyValuePairs);</div>
|
|
87 <p>Adds multiple key and value pairs specified in array <em>KeyValuePairs</em> to pseudo heap
|
|
88 using a new or existing keys and returns <strong>PseudoHeap</strong>.</p>
|
|
89 </dd>
|
|
90 <dt><strong><a name="deletekey" class="item"><strong>DeleteKey</strong></a></strong></dt>
|
|
91 <dd>
|
|
92 <div class="OptionsBox">
|
|
93 $PseudoHeap->DeleteKey($Key);</div>
|
|
94 <p>Deletes a specified <em>Key</em> from pseudo heap and returns <strong>PseudoHeap</strong>.</p>
|
|
95 </dd>
|
|
96 <dt><strong><a name="deletekeys" class="item"><strong>DeleteKeys</strong></a></strong></dt>
|
|
97 <dd>
|
|
98 <div class="OptionsBox">
|
|
99 $PseudoHeap->DeleteKeys(@Keys);</div>
|
|
100 <p>Deletes a specified <em>Keys</em> from pseudo heap and returns <strong>PseudoHeap</strong>.</p>
|
|
101 </dd>
|
|
102 <dt><strong><a name="deletemaxkey" class="item"><strong>DeleteMaxKey</strong></a></strong></dt>
|
|
103 <dd>
|
|
104 <div class="OptionsBox">
|
|
105 $PseudoHeap->DeleteMaxKey();</div>
|
|
106 <p>Deletes a <em>MaxKey</em> along with its associated values from pseudo heap and returns
|
|
107 <strong>PseudoHeap</strong>.</p>
|
|
108 </dd>
|
|
109 <dt><strong><a name="deleteminkey" class="item"><strong>DeleteMinKey</strong></a></strong></dt>
|
|
110 <dd>
|
|
111 <div class="OptionsBox">
|
|
112 $PseudoHeap->DeleteMinKey();</div>
|
|
113 <p>Deletes a <em>MinKey</em> along with its associated values from pseudo heap and returns
|
|
114 <strong>PseudoHeap</strong>.</p>
|
|
115 </dd>
|
|
116 <dt><strong><a name="getcurrentsize" class="item"><strong>GetCurrentSize</strong></a></strong></dt>
|
|
117 <dd>
|
|
118 <div class="OptionsBox">
|
|
119 $Size = $PseudoHeap->GetCurrentSize();</div>
|
|
120 <p>Returns current <em>Size</em> of pseudo heap corresponding to number to keys in heap.</p>
|
|
121 </dd>
|
|
122 <dt><strong><a name="getkeytype" class="item"><strong>GetKeyType</strong></a></strong></dt>
|
|
123 <dd>
|
|
124 <div class="OptionsBox">
|
|
125 $KeyType = $PseudoHeap->GetKeyType();</div>
|
|
126 <p>Returns <em>KeyType</em> of pseudo heap. Possible <strong>KeyType</strong> values: <em>Numeric or Alphanumeric</em>.</p>
|
|
127 </dd>
|
|
128 <dt><strong><a name="getkeyvalues" class="item"><strong>GetKeyValues</strong></a></strong></dt>
|
|
129 <dd>
|
|
130 <div class="OptionsBox">
|
|
131 @Values = $PseudoHeap->GetKeyValues($Key);
|
|
132 <br/> $NumOfValues = $PseudoHeap->GetKeyValues($Key);</div>
|
|
133 <p>Returns an array containing <strong>Values</strong> associated with a specified <em>Key</em> in pseudo heap. In
|
|
134 scalar context, it returns number of values associated with a key.</p>
|
|
135 </dd>
|
|
136 <dt><strong><a name="getkeys" class="item"><strong>GetKeys</strong></a></strong></dt>
|
|
137 <dd>
|
|
138 <div class="OptionsBox">
|
|
139 @Keys = $PseudoHeap->GetKeys();
|
|
140 <br/> $NumOfKeys = $PseudoHeap->GetKeys();</div>
|
|
141 <p>Returns an array containing all <strong>Keys</strong> in pseudo heap. In scalar context, it returns total
|
|
142 number of keys.</p>
|
|
143 </dd>
|
|
144 <dt><strong><a name="getmaxkey" class="item"><strong>GetMaxKey</strong></a></strong></dt>
|
|
145 <dd>
|
|
146 <div class="OptionsBox">
|
|
147 $MaxKey = $PseudoHeap->GetMaxKey();</div>
|
|
148 <p>Returns <em>MaxKey</em> present in pseudo heap.</p>
|
|
149 </dd>
|
|
150 <dt><strong><a name="getmaxsize" class="item"><strong>GetMaxSize</strong></a></strong></dt>
|
|
151 <dd>
|
|
152 <div class="OptionsBox">
|
|
153 $MaxSize = $PseudoHeap->GetMaxSize();</div>
|
|
154 <p>Returns <em>MaxSize</em> of pseudo heap.</p>
|
|
155 </dd>
|
|
156 <dt><strong><a name="getminkey" class="item"><strong>GetMinKey</strong></a></strong></dt>
|
|
157 <dd>
|
|
158 <div class="OptionsBox">
|
|
159 $MinKey = $PseudoHeap->GetMinKey();</div>
|
|
160 <p>Returns <em>MinKey</em> present in pseudo heap.</p>
|
|
161 </dd>
|
|
162 <dt><strong><a name="getsortedkeys" class="item"><strong>GetSortedKeys</strong></a></strong></dt>
|
|
163 <dd>
|
|
164 <div class="OptionsBox">
|
|
165 @Keys = $PseudoHeap->GetSortedKeys();
|
|
166 <br/> $NumOfKeys = $PseudoHeap->GetSortedKeys();</div>
|
|
167 <p>Returns an array containing all sorted <strong>Keys</strong> in pseudo heap. In scalar context, it retruns
|
|
168 total number of keys.</p>
|
|
169 <p>Keys are sorted based on values of <strong>Type</strong> and <strong>KeyType</strong> for pseudo heap:</p>
|
|
170 <div class="OptionsBox">
|
|
171 Type KeyType SortOrder SortOperator
|
|
172 <br/> KeepTopN Numeric Descending <=>
|
|
173 <br/> KeepTopN Alphanumeric Descending cmp
|
|
174 <br/> KeepBottomN Numeric Ascending <=>
|
|
175 <br/> KeepBottomN Alphanumeric Ascending cmp</div>
|
|
176 </dd>
|
|
177 <dt><strong><a name="gettype" class="item"><strong>GetType</strong></a></strong></dt>
|
|
178 <dd>
|
|
179 <div class="OptionsBox">
|
|
180 $Type = $PseudoHeap->GetType();</div>
|
|
181 <p>Returns <em>Type</em> of pseudo heap.</p>
|
|
182 </dd>
|
|
183 <dt><strong><a name="setkeytype" class="item"><strong>SetKeyType</strong></a></strong></dt>
|
|
184 <dd>
|
|
185 <div class="OptionsBox">
|
|
186 $PseudoHeap->SetKeyType($KeyType);</div>
|
|
187 <p>Sets <em>KeyType</em> of pseudo heap and returns <strong>PseudoHeap</strong>.</p>
|
|
188 </dd>
|
|
189 <dt><strong><a name="setmaxsize" class="item"><strong>SetMaxSize</strong></a></strong></dt>
|
|
190 <dd>
|
|
191 <div class="OptionsBox">
|
|
192 $PseudoHeap->SetMaxSize($MaxSize);</div>
|
|
193 <p>Sets <em>MaxSize</em> of pseudo heap and returns <strong>PseudoHeap</strong>.</p>
|
|
194 </dd>
|
|
195 <dt><strong><a name="settype" class="item"><strong>SetType</strong></a></strong></dt>
|
|
196 <dd>
|
|
197 <div class="OptionsBox">
|
|
198 $PseudoHeap->SetType($Type);</div>
|
|
199 <p>Sets <em>Type</em> of pseudo heap and returns <strong>PseudoHeap</strong>.</p>
|
|
200 </dd>
|
|
201 <dt><strong><a name="stringifypseudoheap" class="item"><strong>StringifyPseudoHeap</strong></a></strong></dt>
|
|
202 <dd>
|
|
203 <div class="OptionsBox">
|
|
204 $PseudoHeapString = $PseudoHeap->StringifyPseudoHeap();</div>
|
|
205 <p>Returns a string containing information about <em>PseudoHeap</em> object</p>
|
|
206 </dd>
|
|
207 </dl>
|
|
208 <p>
|
|
209 </p>
|
|
210 <h2>AUTHOR</h2>
|
|
211 <p><a href="mailto:msud@san.rr.com">Manish Sud</a></p>
|
|
212 <p>
|
|
213 </p>
|
|
214 <h2>COPYRIGHT</h2>
|
|
215 <p>Copyright (C) 2015 Manish Sud. All rights reserved.</p>
|
|
216 <p>This file is part of MayaChemTools.</p>
|
|
217 <p>MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
218 the terms of the GNU Lesser General Public License as published by the Free
|
|
219 Software Foundation; either version 3 of the License, or (at your option)
|
|
220 any later version.</p>
|
|
221 <p> </p><p> </p><div class="DocNav">
|
|
222 <table width="100%" border=0 cellpadding=0 cellspacing=2>
|
|
223 <tr align="left" valign="top"><td width="33%" align="left"><a href="./PeriodicTable.html" title="PeriodicTable.html">Previous</a> <a href="./index.html" title="Table of Contents">TOC</a> <a href="./SDFileUtil.html" title="SDFileUtil.html">Next</a></td><td width="34%" align="middle"><strong>March 29, 2015</strong></td><td width="33%" align="right"><strong>PseudoHeap.pm</strong></td></tr>
|
|
224 </table>
|
|
225 </div>
|
|
226 <br />
|
|
227 <center>
|
|
228 <img src="../../images/h2o2.png">
|
|
229 </center>
|
|
230 </body>
|
|
231 </html>
|