NAME
List::DoubleLinked - Double Linked Lists for Perl
VERSION
version 0.002
SYNOPSIS
use List::DoubleLinked;
my $list = List::DoubleLinked->new(qw/foo bar baz/);
$list->begin->insert_after(qw/quz/);
$list->end->previous->erase;
DESCRIPTION
This module provides a double linked list for Perl. You should ordinarily use arrays instead of this, they are faster for almost any usage. However there is a small set of use-cases where linked lists are necessary. This module was written in particular to offer stable iterators (iterators that will remain valid even if other elements are added or removed anywhere in the list).
METHODS
new(@elements)
Create a new double linked list. @elements is pushed to the list.
flatten()
Return an array containing the same values as the list does. This runs in linear time.
push(@elements)
Add @elements to the end of the list.
pop()
Remove an element from the end of the list and return it
unshift(@elements)
Add @elements to the start of the list.
shift()
Remove an element from the end of the list and return it
front()
Return the first element in the list
back()
Return the last element in the list.
empty()
Returns true if the list has no elements in it, returns false otherwise.
size()
Return the length of the list. This runs in linear time.
begin()
Return an iterator to the first element of the list.
end()
Return an iterator to the last element of the list.
erase($iterator)
Remove the element under $iterator.
insert_before($iterator, @elements)
Insert @elements before $iterator.
insert_after($iterator, @elements)
Insert @elements after $iterator.
AUTHOR
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.