Subject: | unclear documentation for Tree::AVL::acc_lookup() |
Date: | Sat, 12 Nov 2011 16:37:14 -0500 (EST) |
To: | bug-Tree-AVL [...] rt.cpan.org |
From: | Jonathan Thornburg <jthorn [...] astro.indiana.edu> |
Hi,
I'm using your Tree::AVL perl module (version 1.075, downloaded from
cpan a day or two ago, with perl 5.12.2 on OpenBSD 5.0-release), and
I'm delighted with the functionality it provides. The purpose of this
message is to (a) thank you for providing such a *great* module, and
(b) point out what seems to me to be a documentation bug: the result
returned by acc_lookup() is different from what the documentation
describes.
In particular, the documentation states:
Show quoted text
> acc_lookup()
> my @found_things = $avltree->acc_lookup($thing, $partial_cmp_func, $p
> recise_cmp_func);
>
> Accumulative lookup; returns a list of all items whose keys satisfy the
> match function for the key for $object.
which to me says that acc_lookup() returns a list of (references to)
tree nodes (I presume that's what's mean by the word "items") satisfying
the partial-comparison equality criterion.
To see if I understood this properly, I wrote a simple test program
(attached, along with its output) which sets up a Tree::AVL of 3 nodes,
each (a reference to) an anonmous hash
{
_time => number
_modes => [list of numbers]
}
then uses acc_lookup() to look for all nodes with _time close to a
specified value, then uses Data::Dumper() to print the returned result
of acc_lookup() . The result is that acc_lookup() is returning a
list of the _time values, not a list of (references to) the nodes:
looking for nodes near time 41.9999999999
found 2 nodes:
$VAR1 = '42.0000000001';
$VAR2 = 42;
suggesting that the returned result was a 2-element list of the keys
(here 42+1e-10 and 42), rather than a 2-element list of references to
the tree nodes themselves (which would have had additional data printed).
Looking at the Tree::AVL source code (AVL.pm, lines 1040-1045), it also
seems to be accumulating a list of node keys:
Show quoted text> if($partial_cmp == 0){ # found a match on partial cmp
>
> if(!$acc_results){
> @$acc_results = ();
> }
> push(@$acc_results, $node_key);
I'm attaching 4 files:
* foo = a simple test program which creates 3 objects of a simple tree-node
class, inserts them into a Tree::AVL, and does an acc_lookup()
to find all those close to a certain key
* foo.out = the output of this program on my computer
* perl-V = the output of 'perl -V' on my computer
* uname-a = the output of 'uname -a' on my computer
thanks, ciao,
--
-- Jonathan Thornburg <jthorn@astro.indiana.edu>
Dept of Astronomy & IUCSS, Indiana University, Bloomington, Indiana, USA
"Washing one's hands of the conflict between the powerful and the
powerless means to side with the powerful, not to be neutral."
-- quote by Freire / poster by Oxfam
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.
Message body is not shown because sender requested not to inline it.