use PseudoHeap qw(:all);
PseudoHeap class provides the following methods:
new, AddKeyValuePair, AddKeyValuePairs, DeleteKey, DeleteKeys, DeleteMaxKey, DeleteMinKey, GetCurrentSize, GetKeyType, GetKeyValues, GetKeys, GetMaxKey, GetMaxSize, GetMinKey, GetSortedKeys, GetType, SetKeyType, SetMaxSize, SetType, StringifyPseudoHeap
PseudoHeap is designed to support tracking of a specific number of largest or smallest key/value pairs with numeric or alphanumeric keys along with corresponding scalar or reference values.
Although PseudoHeap is conceptually similar to a heap, it lacks number of key properties of a traditional heap data structure: no concept of root, parent and child nodes; no ordering of keys in any particular order; no specific location greatest or smallest key.
The keys are simply stored in a hash with each key pointing to an array containing specified values. The min/max keys are updated during addition and deletion of key/value pairs; these can be retrieved by accessing corresponding hash.
Addition and deletion of key/value is also straightforward using hashes. However, min/max keys need to be identified which is done using Perl sort function on the keys.
Using specified parameters NamesAndValues names and values hash, new method creates a new object and returns a reference to a newly created NewPseudoHeap object. By default, the following property names are initialized:
Add specified Key and Value pair to pseudo heap using a new or an existing key and returns PseudoHeap.
Adds multiple key and value pairs specified in array KeyValuePairs to pseudo heap using a new or existing keys and returns PseudoHeap.
Deletes a specified Key from pseudo heap and returns PseudoHeap.
Deletes a specified Keys from pseudo heap and returns PseudoHeap.
Deletes a MaxKey along with its associated values from pseudo heap and returns PseudoHeap.
Deletes a MinKey along with its associated values from pseudo heap and returns PseudoHeap.
Returns current Size of pseudo heap corresponding to number to keys in heap.
Returns KeyType of pseudo heap. Possible KeyType values: Numeric or Alphanumeric.
Returns an array containing Values associated with a specified Key in pseudo heap. In scalar context, it returns number of values associated with a key.
Returns an array containing all Keys in pseudo heap. In scalar context, it returns total number of keys.
Returns MaxKey present in pseudo heap.
Returns MaxSize of pseudo heap.
Returns MinKey present in pseudo heap.
Returns an array containing all sorted Keys in pseudo heap. In scalar context, it retruns total number of keys.
Keys are sorted based on values of Type and KeyType for pseudo heap:
Returns Type of pseudo heap.
Sets KeyType of pseudo heap and returns PseudoHeap.
Sets MaxSize of pseudo heap and returns PseudoHeap.
Sets Type of pseudo heap and returns PseudoHeap.
Returns a string containing information about PseudoHeap object
Copyright (C) 2019 Manish Sud. All rights reserved.
This file is part of MayaChemTools.
MayaChemTools is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.