Skip Menu |
 

This queue is for tickets about the Array-Iterator CPAN distribution.

Report information
The Basics
Id: 126034
Status: open
Priority: 0/
Queue: Array-Iterator

People
Owner: Nobody in particular
Requestors: l.declercq [...] nuxwin.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Unexpected behavior when with getPrevious() method from the BiDirectional interator
Date: Fri, 10 Aug 2018 12:20:39 +0200
To: bug-Array-Iterator [...] rt.cpan.org
From: Declercq Laurent <l.declercq [...] nuxwin.com>
Download (untitled) / with headers
text/plain 2.1k
Good morning, Either I'm totally crazy, either the BiDirectional iterator is totally broken. my @set = qw/ one two three four /: my $iterator = Array::Iterator::BiDirectional->new(@set); Current behavior print $iterator->getNext() . "\n";       # one print $iterator->getNext() . "\n";       # two print $iterator->getNext() . "\n";       # three print $iterator->getPrevious() . "\n"; # three print $iterator->getPrevious() . "\n"; # two Expected behavior print $iterator->getNext() . "\n";       # one print $iterator->getNext() . "\n";       # two print $iterator->getNext() . "\n";       # three print $iterator->getPrevious() . "\n"; # two print $iterator->getPrevious() . "\n"; # one Environment lsb_release -a No LSB modules are available. Distributor ID:    Debian Description:    Debian GNU/Linux 8.11 (jessie) Release:    8.11 Codename:    jessie # perl --version This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux-gnu-thread-multi (with 102 registered patches, see perl -V for more detail) Copyright 1987-2015, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl".  If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. Module version: 0.11 -- Laurent Declercq iHMS/i-MSCP CEO & Lead Developer ------------------------------------------------------------------------ This message and any attachment are intended solely for the addressees and are confidential. iHMS/i-MSCP, including any part representing these entities may not be held responsible for their contents whose accuracy and completeness cannot be guaranteed over the Internet. Unauthorized use, disclosure, distribution, copying, or any part thereof is strictly prohibited. If you are not the intended recipient of this message, please notify the sender immediately and delete it. ------------------------------------------------------------------------
Download l_declercq.vcf
text/x-vcard 328b

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 659b
Yes, you're right. The current implementation is broken in that getNext() will retrieve an item *and then* move the pointer to the next. And then currentItem() resorts to -1 arithmetic, complicating things. This is incompatible with getPrevious(). It tries to move the pointer back one first, and ends up with the current item. Note that I'm not the original author. I'm not sure how the original author (STEVAN) intended Array::Iterator::BiDirectional to be used, perhaps he meant getPrevious() to be called only after the getNext() has been exhausted. Currently I don't have enough time and motivation to fix this module, I'm putting it up for adoption.
Download (untitled) / with headers
text/plain 197b
Forgot to add this: getPrevious() *could* move the pointer back one first, then move it back another one. But it needs to detect that getNext() has been called first. It's better to fix getNext().


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.