NAME

Doubly::Linked - Doubly linked lists

VERSION

Version 0.02

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 = $list->remove;

$list = $list->find(sub { return ... ? 1 : 0 });

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");

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:

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)