# SplDoublyLinkedList missing insertBefore/After

- Thread: https://externals.io/message/64099
- Original archive: https://news-web.php.net/php.internals/64099
- Started by Rafael Dohms on 2012-11-29T11:38:06+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #64099 — Rafael Dohms — 2012-11-29T11:38:06+00:00

URL: https://externals.io/message/64099#64099

I have just noticed that the current SPL inplementation of a
DoublyLinkedList does not include methods to insert nodes into the middle
of the list (insertBefore, insertAfter).

After mentioning it I ran into a few people and other outbursts on the
internet of more people who saw this and complained about it.

I found a bug from 2009 (https://bugs.php.net/bug.php?id=48358) which
mentions the case and has no Core response at all.

I ask two questions:

1) Why was this bug never replied to, is there some reason these methods
should not be implemented?

2) Is anyone willing to put up a patch for this? I imagine that if you are
familiar with C and PHP source this is a quick implementation as its
standard logic documented everywhere.

I'm not familiar enough with the PHP source to do this myself, hence I'm
asking for anyone willing to "champion" the patch.

Thanks!

-- 
Rafael Dohms
PHP Evangelist and Community Leader
http://www.rafaeldohms.com.br
http://www.amsterdamphp.nl

---

## #64101 — Paul Dragoonis — 2012-11-29T13:28:14+00:00

URL: https://externals.io/message/64099#64101 · In reply to: #64099

Hi Rafael,

I have worked on this code before and if the idea is accepted I'm happy to
add features to this class.

Let me know.
Thanks,
Paul.


On Thu, Nov 29, 2012 at 11:38 AM, Rafael Dohms <listas@rafaeldohms.com.br>wrote:

> I have just noticed that the current SPL inplementation of a
> DoublyLinkedList does not include methods to insert nodes into the middle
> of the list (insertBefore, insertAfter).
>
> After mentioning it I ran into a few people and other outbursts on the
> internet of more people who saw this and complained about it.
>
> I found a bug from 2009 (https://bugs.php.net/bug.php?id=48358) which
> mentions the case and has no Core response at all.
>
> I ask two questions:
>
> 1) Why was this bug never replied to, is there some reason these methods
> should not be implemented?
>
> 2) Is anyone willing to put up a patch for this? I imagine that if you are
> familiar with C and PHP source this is a quick implementation as its
> standard logic documented everywhere.
>
> I'm not familiar enough with the PHP source to do this myself, hence I'm
> asking for anyone willing to "champion" the patch.
>
> Thanks!
>
> --
> Rafael Dohms
> PHP Evangelist and Community Leader
> http://www.rafaeldohms.com.br
> http://www.amsterdamphp.nl

---

## #64109 — Levi Morrison — 2012-11-29T17:34:02+00:00

URL: https://externals.io/message/64099#64109 · In reply to: #64099

> I have just noticed that the current SPL inplementation of a
> DoublyLinkedList does not include methods to insert nodes into the middle
> of the list (insertBefore, insertAfter).
>
> After mentioning it I ran into a few people and other outbursts on the
> internet of more people who saw this and complained about it.
>
> I found a bug from 2009 (https://bugs.php.net/bug.php?id=48358) which
> mentions the case and has no Core response at all.
>
> I ask two questions:
>
> 1) Why was this bug never replied to, is there some reason these methods
> should not be implemented?
>
> 2) Is anyone willing to put up a patch for this? I imagine that if you are
> familiar with C and PHP source this is a quick implementation as its
> standard logic documented everywhere.

I am creating a library in PHP code that includes a linked list with
this feature (https://github.com/morrisonlevi/PHP-Datastructures/blob/master/src/Spl/LinkedList.php).
I'd love for you to use it while you wait for the core to be patched
and give me some feedback.

---

## #64112 — Daniel Ribeiro Gomes — 2012-11-29T18:26:08+00:00

URL: https://externals.io/message/64099#64112 · In reply to: #64109

It would be an awesome feature, indeed.


Daniel Ribeiro Gomes Pereira
Twitter <https://twitter.com/#!/drgomesp> |
Facebook<https://www.facebook.com/profile.php?id=100000407054469>
 | LinkedIn <http://www.linkedin.com/pub/daniel-ribeiro-gomes/21/414/39>
iPhone: +55 (48) 9111-0931



2012/11/29 Levi Morrison <morrison.levi@gmail.com>

> On Thu, Nov 29, 2012 at 4:38 AM, Rafael Dohms <listas@rafaeldohms.com.br>
> wrote:
> > […]
> are
> > […]
>
> I am creating a library in PHP code that includes a linked list with
> this feature (
> https://github.com/morrisonlevi/PHP-Datastructures/blob/master/src/Spl/LinkedList.php
> ).
> I'd love for you to use it while you wait for the core to be patched
> and give me some feedback.
