NAME

DataStructure::LinkedList

SYNOPSIS

A linked list data-structure, written in pure Perl.

See also DataStructure::DoubleList for a double-linked list version that offers a richer interface.

DESCRIPTION

CONSTRUCTOR

DataStructure::LinkedList-new()>

Creates an empty list.

METHODS

All the functions below are class methods that should be called on a DataStructure::LinkedList object. Unless documented, they run in constant time.

first()

Returns the first DataStructure::LinkedList::Node of the list, or undef if the list is empty.

unshift($value)

Adds a new node at the beginning of the list with the given value. Returns the newly added node.

For conveniance, push() can be used as a synonym of unshift().

shift()

Removes the first node of the list and returns its value. Returns undef if the list is empty. Note that the method can also return undef if the first node’s value is undef

For conveniance, pop() can be used as a synonym of shift().

size()

Returns the number of nodes in the list.

empty()

Returns whether the list is empty.

values()

Returns all the values of the list, as a normal Perl list. This runs in linear time with the size of the list.

AUTHOR

Mathias Kende <mathias@cpan.org>

LICENCE

Copyright 2021 Mathias Kende

This program is distributed under the MIT (X11) License: http://www.opensource.org/licenses/mit-license.php

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

SEE ALSO

DataStructure::DoubleList

1 POD Error

The following errors were encountered while parsing the POD:

Around line 88:

Non-ASCII character seen before =encoding in 'node’s'. Assuming UTF-8