|
|
| Pathologically Eclectic Rubbish Lister | |
| PerlMonks |
Re: Linked list in Perlby grizzley (Chaplain) |
| on Sep 28, 2012 at 12:21 UTC ( #996195=note: print w/ replies, xml ) | Need Help?? |
|
Linked list is best if you need to add at the end and pick from beginning. If you want to insert/remove elements in the middle you have to travel from the beginning and if you are at desired element C (after which you want to insert new element N) just copy link to next element from C to N, set link to next element in C to N and you are done. So you want to change C -> nextElem toC -> N -> nextElem
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||