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

From: Date: Tue, 03 Oct 2006 21:01:37 +0000
Subject: Re: [PEPr] +1 for Structures::Structures_LinkedList
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-44281@lists.php.net to get a copy of this message
Dan Scott wrote: > 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. [...] Okay, maybe a "nice to have", but you should note somewhere how expensive this is and that people should better use the double linked list for such things (which should be obvious to most people, but warning the other people might be a good idea). > So, on this basis I hope that you would reconsider making your vote > conditional on previous() returning false in a singly-linked list. Yes, as said: I did not run the examples; if they work, that's fine. But the CS issues should be fixed, of course. Especially the wrong require statements. Regards, Mark

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