NAME
Doubly::Linked - Doubly linked lists
VERSION
Version 0.10
SYNOPSIS
use Doubly::Linked;
my $list = Doubly::Linked->new();
$list->insert_at_start(1);
$list = $list->insert_at_end(2);
$list->insert_after(3);
$list = $list->start;
$list = $list->next;
$list = $list->prev;
$list->data;
$list->data($new_data);
$list->remove;
$list = $list->find(sub { return ... ? 1 : 0 });
DESCRIPTION
A doubly linked list is a type of linked list in which each node contains 3 parts, a data part and two addresses, one points to the previous node and one for the next node. It differs from the singly linked list as it has an extra pointer called previous that points to the previous node, allowing the traversal in both forward and backward directions.

SUBROUTINES/METHODS
new
Instantiate a new Doubly::Linked list. Optionally you can pass the value for the first item in the list else that will get set when you first call an insert* method.
my $list = Doubly::Linked->new({ a => 1, b => 2, c => 3});
data
Access the data for the current item in the list.
$list->data;
start
Goto the start of the list.
$list = $list->start;
is_start
returns true if the current item is the start of the list
$list->is_start;
end
Goto the end of the list.
$list = $list->end;
is_end
returns true if the current item is the end of the list
next
Goto the next item in the list.
$list = $list->next;
prev
Goto the previous item in the list.
$list = $list->prev;
add
Alias for insert_at_end, it adds a new item to the end of the list.
$list->add([qw/1 2 3/]);
insert
Insert a new item in the list based on the first match from the cb subroutine.
$list->insert(sub { ref $_[0] eq 'HASH' }, { d => 4 });
insert_before
Insert a new item before the current item.
$list->insert_before(100);
insert_after
Insert a new item after the current item.
$list->insert_after(200);
insert_at_start
Insert a new item at the start of the list.
$list->insert_at_start("start");
insert_at_end
Insert a new item at the end of the list.
$list->insert_at_end("end");
insert_at_pos
Insert a new item by index from the start of the list.
$list->insert_at_pos(2, "third");
remove
Remove the current item.
$list->remove();
remove_from_start
Remove the first item from the list.
$list->remove_from_start();
remove_from_end
Remove the last item from the list.
$list->remove_from_end();
remove_from_pos
Remove an item by index from the list.
$lst->remove_from_pos($index);
find
Itterate the list from the start until a match is found for the cb.
$list = $list->find(sub { (ref $_[0] || "") eq 'HASH' && $_[0]->{a} == 1 ? 1 : 0 });
AUTHOR
LNATION, <email at lnation.org>
BUGS
Please report any bugs or feature requests to bug-doubly-linked at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Doubly-Linked. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Doubly::Linked
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
LICENSE AND COPYRIGHT
This software is Copyright (c) 2025 by LNATION.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)