Re: Re: [PEPr] +1 for Structures::Structures_LinkedList

From: Date: Tue, 03 Oct 2006 21:30:01 +0000
Subject: Re: Re: [PEPr] +1 for Structures::Structures_LinkedList
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44283@lists.php.net to get a copy of this message
On 03/10/06, Anant Narayanan <anant@kix.in> wrote:
Hi Dan, 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. It's not about whether you're able to do it or not. When you're implementing a singly-linked list, you have to provide an honest implementation of it, simply because everyone who has taken a course on Data Structures will not expect to be able to use the previous() method. Take the stack for example. It's a very simple data structure, with just three methods. If you would start adding "convenience" methods to it, which you can of course, it just becomes a queue, or even worse: an array! Correctness over Convenience :) Cheers, - Anant
Heh, okay. Point taken. Maybe in a future release I'll add a Structures_LinkedList_SingleButConvenient class :) Dan

« previous php.pear.dev (#44283) next »