0.0
No commit activity in last 3 years
No release in over 3 years
Provides a circular linked list data structure for Ruby with the most common methods
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 2.0, < 3.0
~> 3.10
 Project Readme

Circular Linked List

Implementation for the circular linked list data structure for Ruby.

List is composed by nodes, which have each one a value and a next item.

Installation

Just add to your Gemfile:

gem "circular_linked"

Then

$ bundle install

Or you can install the gem directly from terminal:

$ gem install circular_linked

Usage

items_list = CircularLinked::List.new(1, 2, 3)
empty_list = CircularLinked::List.new

items_list.head #=> #<Node:0x... @value=1 ...
empty_list.head #=> nil

items_list.add(4) # List now have nodes with the values: 1, 2, 3, 4

items_list.last_node #=> #<Node:0x... @value=4 ...
empty_list.last_node #=> nil

items_list.find(2) #=> #<Node:0x... @value=2 ...
empty_list.find(2) #=> nil

items_list.remove(3) # List now have nodes with the values: 1, 2, 4
empty_list.remove(3) # List remains empty

items_list.items_value #=> [1,2,4]
empty_list.items_value #=> []

items_list.length #=> 3
empty_list.length #=> 0

items_list.each {|node| puts node.value }
#=> 1
#=> 2
#=> 4
empty_list.each {|node| puts node.value }
#=>

Development

Just run bundle install to install the dependencies and you are ready.

Tests

To run the specs, after installing the dependecies as said above, you can just run in the main folder:

$ rspec .

Contributing

Feel free to open pull requests/issues or to fork this repo.