Req #48358 [Com]: SplDoublyLinkedList needs an insertAfterIterator() method or something similar

From: Date: Sat, 22 May 2010 11:46:01 +0000
Subject: Req #48358 [Com]: SplDoublyLinkedList needs an insertAfterIterator() method or something similar
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-150729@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=48358&edit=1 ID: 48358 Comment by: 1000235409 at smail dot shnu dot edn dot cn Reported by: dannel at aaronexodus dot com Summary: SplDoublyLinkedList needs an insertAfterIterator() method or something similar Status: Assigned Type: Feature/Change Request Package: Feature/Change Request PHP Version: 5.3.0RC2 Assigned To: colder New Comment: i have encountered the same problem today, after this was modified for 1 year... but i have a solution to solve this problem. write anohter class with a lots of spldoublylinkedlists inside it. however, complex algorithm may be used... Previous Comments: ------------------------------------------------------------------------ [2009-05-21 17:02:15] dannel at aaronexodus dot com Description: ------------ The SplDoublyLinkedList is great, but it lacks a way to insert a node somewhere in the middle of the list. One could technically extend the class and provide that functionality, but due to the fact that there seem to be [documented] data members in SplDoublyLinkedList, the only way to do it would be to find the reference node, insert the new node, and move all of the following nodes up one slot in the list, resulting in O(n) performance for an insert. I propose adding an insertAfterIterator() method which would place the new node after the current node the iterator points to. Another option could be an insertAfterArrayKey() method which would act similarly, but would find the reference node via a given array key, which might be a little more straightforward to use in code. Each should probably have an insertBefore*() counterpart as well. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=48358&edit=1

« previous php.bugs (#150729) next »