Ancient
view release on metacpan or search on metacpan
lib/doubly.pm view on Meta::CPAN
XSLoader::load('doubly', $VERSION);
1;
__END__
=head1 NAME
doubly - doubly linked list
=head1 SYNOPSIS
use doubly;
my $list = doubly->new(1);
$list->add(2)->add(3);
# Navigation
$list = $list->start; # Go to head
$list = $list->end; # Go to tail
$list = $list->next; # Move to next node
$list = $list->prev; # Move to previous node
# Data access
my $data = $list->data; # Get current node's data
$list->data("new value"); # Set current node's data
# Insertion
my $new = $list->insert_before("value");
my $new = $list->insert_after("value");
$list->insert_at_start("first");
$list->insert_at_end("last");
# Removal
my $removed = $list->remove;
my $removed = $list->remove_from_start;
my $removed = $list->remove_from_end;
# Utility
my $length = $list->length;
my $is_start = $list->is_start;
my $is_end = $list->is_end;
# Search
my $found = $list->find(sub { $_[0] eq "target" });
=head1 DESCRIPTION
My fastest doubly linked list implementation without JIT or building via a class/schema.
This module provides full API compatibility with the Doubly module but
runs approximately 3x faster.
This implementation is not thread-safe, the lists cannot be shared across threads.
=head2 Architecture
=over 4
=item * Dynamic SV-based node storage (no serialization overhead)
=item * Index-based linking with global registry
=item * Reference counting for automatic garbage collection
=back
=head1 METHODS
=head2 new
my $list = doubly->new();
my $list = doubly->new($initial_data);
Create a new doubly linked list, optionally with initial data.
=head2 length
my $len = $list->length;
Returns the number of nodes in the list.
=head2 data
my $data = $list->data; # getter
$list->data($new_value); # setter
Get or set the data of the current node.
=head2 start
my $start = $list->start;
Returns a new list object pointing to the head of the list.
=head2 end
my $end = $list->end;
Returns a new list object pointing to the tail of the list.
=head2 next
my $next = $list->next;
Returns a new list object pointing to the next node, or undef if at end.
=head2 prev
my $prev = $list->prev;
Returns a new list object pointing to the previous node, or undef if at start.
=head2 is_start
if ($list->is_start) { ... }
Returns true if the current node is the head of the list.
=head2 is_end
if ($list->is_end) { ... }
( run in 0.502 second using v1.01-cache-2.11-cpan-df04353d9ac )