Re: [PEPr] +1 for Structures::Structures_LinkedList
| From: | Dan Scott | Date: | Tue, 03 Oct 2006 20:55:55 +0000 |
| Subject: | Re: [PEPr] +1 for Structures::Structures_LinkedList | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-44280@lists.php.net to get a copy of this message | ||
On 3 Oct 2006 20:40:08 -0000, Mark Wiesemann <wiesemann@php.net> wrote:
Mark Wiesemann (http://pear.php.net/user/wiesemann) has voted +1 on the proposal for Structures::Structures_LinkedList. Proposal information: http://pear.php.net/pepr/pepr-proposal-show.php?id=444 Vote information: http://pear.php.net/pepr/pepr-vote-show.php?id=444&handle=wiesemann This vote is conditional. The condition is: - fix the issues mentioned by Anant and Christian (didn't try to run the example code, but previous() returns false and it does not make sense for single linked lists) -- Sent by PEPr, the automatic proposal system at http://pear.php.netHi Mark and Christian: I just wanted to note that previous() actually can work for singly-linked lists, as you can see in the implementation of _getPreviousNode(). The list knows the root node, and it also knows your current node, so it just has to iterate through each node starting at the root until it finds an === match for the current node and then return the previous node (which it remembers along the way). It's horribly expensive if you have to use previous() a lot, but because it is possible I think it would be best to keep the implementation and strongly recommend a doubly-linked list if you expect to use previous() more than a handful of times. So, on this basis I hope that you would reconsider making your vote conditional on previous() returning false in a singly-linked list. And yes, the examples need to be brought up to date and corrected. Sigh. I love unit tests; I'll have to update my package-publishing script to automatically test my examples too. Dan