wdatastructure
is a Ruby gem that provides a collection of data structure.
This gem is designed to demonstrate the implementation of basic data structures in Ruby.
- Linked List: A data structure that consists of a sequence of elements, where each element points to the next one.
list.append(value)
: Adds a value to the end of the list.list.prepend(value)
: Inserts a value at the beginning of the list.list.find(value)
: Searches for a node by its value.list.each
: Iterates over each element in the list.list.to_a
: Converts the linked list to an array.list.empty?
: Checks if the list is empty.list.size
: Returns the number of elements in the list.list.display
: Prints the elements of the list to the console.
list = DataTypes::LinkedList.new
list.append(1)
list.append(2)
list.prepend(0)
list.display # Outputs: 0, 1, 2
list.find(1) # Returns the node with value 1
list.to_a #=> [0, 1, 2]
list.size #=> 3
list.empty? #=> false
-
gem build ./wdatastructure.gemspec
-
gem install 'build_name'
-
gem install wdatastructure
-
bundle exec rspec
- Fork it ( https://github.com/W1ldr/wdatastructure.rb.git )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request