Socket
Book a DemoInstallSign in
Socket

circular_linked

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

circular_linked

0.1.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

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 #=> 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.

FAQs

Package last updated on 02 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.