Class Hashery::LinkedList
In: lib/hashery/linked_list.rb
Parent: Object

LinkedList implements a simple doubly linked list with efficient hash-like element access.

This is a simple linked-list implementation with efficient random access of data elements. It was inspired by George Moscovitis’ LRUCache implementation found in Facets 1.7.30, but unlike the linked-list in that cache, this one does not require the use of a mixin on any class to be stored. The linked-list provides the push, pop, shift, unshift, first, last, delete and length methods which work just like their namesakes in the Array class, but it also supports setting and retrieving values by key, just like a hash.

LinkedList was ported from the original in Kirk Hanes IOWA web framework.

Acknowledgements

LinkedList is based on the LinkedList library by Kirk Haines.

Copyright (C) 2006 Kirk Haines <khaines@enigo.com>.

Methods

<<   []   []=   delete   each   empty?   first   last   length   new   pop   push   queue   shift   size   to_a   unshift  

Included Modules

Enumerable

Classes and Modules

Class Hashery::LinkedList::Node

Public Class methods

Initialize new LinkedList instance.

Public Instance methods

<<(v)

Alias for push

Lookup entry by key.

Add node to linked list.

Remove node idenified by key.

Iterate over nodes, starting with the head node and ending with the tail node.

Is linked list empty?

Get value of first node.

Get value of last node.

Number of nodes.

Produces an Array of key values.

Returns [Array].

size()

Alias for length

Converts to an Array of node values.

Returns [Array].

[Validate]