doubly_linked_list 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +25 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +14 -0
- data/README.md +80 -0
- data/Rakefile +1 -0
- data/doubly_linked_list.gemspec +32 -0
- data/lib/doubly_linked_list.rb +148 -0
- data/spec/doubly_linked_list_spec.rb +202 -0
- data/spec/spec_helper.rb +22 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a60119aac53e771266ee26d0800d7f2f5c0f3594
|
4
|
+
data.tar.gz: a6e536f8ce4e2875fa9f82126054182ac26378f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 569c6d1e4c393fc235344a93d52fa4da7550d51bc25855939e9fc71ab759a7e43fdb2132970465e66bed22d2a8e133139584155ec9e110c59472a4db6749e8e4
|
7
|
+
data.tar.gz: 219a455c841d653e158eaea842a11d96d5529f8d923301b680bcd484623dbe2c02906a28d947adb18f95600b10dd3b424b4f72d1e2bf077e61a9dc3adff895e3
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.idea
|
24
|
+
.ruby-gemset
|
25
|
+
.ruby-version
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
Copyright (c) 2014 Cornell University
|
2
|
+
|
3
|
+
##########################################################################
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# DoublyLinkedList
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/elrayle/doubly_linked_list.png?branch=master)](https://travis-ci.org/elrayle/doubly_linked_list)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/elrayle/doubly_linked_list/badge.png?branch=master)](https://coveralls.io/r/elrayle/doubly_linked_list?branch=master)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/doubly_linked_list.svg)](http://badge.fury.io/rb/doubly_linked_list)
|
6
|
+
[![Dependency Status](https://www.versioneye.com/ruby/doubly_linked_list/0.0.4/badge.svg)](https://www.versioneye.com/ruby/doubly_linked_list/0.0.4)
|
7
|
+
|
8
|
+
|
9
|
+
Ruby implementation of doubly linked list, following some Ruby idioms.
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
gem 'doubly_linked_list'
|
18
|
+
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle install
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
|
26
|
+
$ gem install doubly_linked_list
|
27
|
+
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
l = DoublyLinkedList.new
|
33
|
+
l.add_last('cat')
|
34
|
+
l.add_last('dog')
|
35
|
+
l.add_first('fish')
|
36
|
+
l.to_a
|
37
|
+
# => ['fish','cat','dog']
|
38
|
+
l.size
|
39
|
+
# => 3
|
40
|
+
|
41
|
+
l = DoublyLinkedList.new :items => ['cat','dog','fish']
|
42
|
+
l.to_a
|
43
|
+
# => ['cat','dog','fish']
|
44
|
+
|
45
|
+
l = DoublyLinkedList.new :list_info => {:title =>'test list', :description => 'Test out my doubly linked list.'},
|
46
|
+
:items => ['cat','dog','rabbit','fish']
|
47
|
+
l.to_a
|
48
|
+
# => ['cat','dog','rabbit','fish']
|
49
|
+
l.list_info
|
50
|
+
# => {:title =>'test list', :description => 'Test out my doubly linked list.'}
|
51
|
+
|
52
|
+
l.remove_first
|
53
|
+
#=> 'cat'
|
54
|
+
l.remove_last
|
55
|
+
#=> 'fish'
|
56
|
+
```
|
57
|
+
|
58
|
+
|
59
|
+
## TODO
|
60
|
+
|
61
|
+
* Insert / delete in the middle
|
62
|
+
* Batch add in the middle
|
63
|
+
* Move item to different position
|
64
|
+
|
65
|
+
|
66
|
+
## Tests
|
67
|
+
|
68
|
+
Run test with
|
69
|
+
|
70
|
+
```shell
|
71
|
+
$ rspec
|
72
|
+
```
|
73
|
+
|
74
|
+
## Contributing
|
75
|
+
|
76
|
+
1. Fork it ( https://github.com/[my-github-username]/doubly_linked_list/fork )
|
77
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
78
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
79
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
80
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'doubly_linked_list'
|
7
|
+
spec.version = '0.0.1'
|
8
|
+
spec.authors = ["E. Lynette Rayle"]
|
9
|
+
spec.email = ["elr37@cornell.edu"]
|
10
|
+
spec.platform = Gem::Platform::RUBY
|
11
|
+
spec.summary = %q{Ruby implementation of doubly_linked_lists using an array to hold and manipulate items.}
|
12
|
+
spec.description = %q{Ruby implementation of doubly_linked_lists using an array to hold and manipulate items.}
|
13
|
+
spec.homepage = "https://github.com/elrayle/doubly_linked_list"
|
14
|
+
spec.license = "APACHE2"
|
15
|
+
spec.required_ruby_version = '>= 1.9.3'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
|
20
|
+
spec.add_development_dependency('pry')
|
21
|
+
spec.add_development_dependency('pry-byebug') # Works with ruby > 2
|
22
|
+
# spec.add_development_dependency('pry-debugger') # Works with ruby < 2
|
23
|
+
spec.add_development_dependency('rdoc')
|
24
|
+
spec.add_development_dependency('rspec')
|
25
|
+
spec.add_development_dependency('coveralls')
|
26
|
+
|
27
|
+
spec.extra_rdoc_files = [
|
28
|
+
"LICENSE.txt",
|
29
|
+
"README.md"
|
30
|
+
]
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,148 @@
|
|
1
|
+
class Array
|
2
|
+
def move(from,to)
|
3
|
+
insert(to, delete_at(from))
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
class DoublyLinkedList
|
8
|
+
## Doubly Linked List implementation
|
9
|
+
#
|
10
|
+
# The list is implemented using an array such that the following linked list concepts are represented as...
|
11
|
+
# * head is the first item in the list
|
12
|
+
# * tail is the last item in the list
|
13
|
+
# * next is the next array element
|
14
|
+
# * prev is the previous array element
|
15
|
+
#
|
16
|
+
|
17
|
+
# include Conversions
|
18
|
+
|
19
|
+
attr_accessor :list_info
|
20
|
+
# attr_writer :node_update_callback # TODO Add callback to update node info
|
21
|
+
|
22
|
+
def initialize(*args)
|
23
|
+
@list = []
|
24
|
+
@list = args[0][:items] if ! args.empty? && args[0].is_a?(Hash) && args[0].key?(:items)
|
25
|
+
@list_info = nil
|
26
|
+
@list_info = args[0][:list_info] if ! args.empty? && args[0].is_a?(Hash) && args[0].key?(:list_info)
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Get the first element of the list.
|
32
|
+
#
|
33
|
+
# @return first node in the list or nil
|
34
|
+
def first
|
35
|
+
return nil if @list.empty?
|
36
|
+
@list[head]
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Get the last element of the list.
|
41
|
+
#
|
42
|
+
# @return last node in the list or nil
|
43
|
+
def last
|
44
|
+
return nil if @list.empty?
|
45
|
+
@list[tail]
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Add data to the end of the list.
|
50
|
+
#
|
51
|
+
# @parameter [Object] data - any object
|
52
|
+
#
|
53
|
+
# @return position where added
|
54
|
+
def add_last(data)
|
55
|
+
@list << data
|
56
|
+
@list.size
|
57
|
+
end
|
58
|
+
alias_method :<<, :add_last
|
59
|
+
|
60
|
+
##
|
61
|
+
# Add data as the first item in the list.
|
62
|
+
#
|
63
|
+
# @parameter [Object] data - any object
|
64
|
+
#
|
65
|
+
# @return position where added
|
66
|
+
def add_first(data)
|
67
|
+
@list.insert(0,data)
|
68
|
+
@list.size
|
69
|
+
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Remove node from the end of the list.
|
73
|
+
#
|
74
|
+
# @return data stored in the removed node
|
75
|
+
def remove_last
|
76
|
+
return nil if @list.empty?
|
77
|
+
@list.delete_at(tail)
|
78
|
+
end
|
79
|
+
|
80
|
+
##
|
81
|
+
# Removes data from the beginning of the list.
|
82
|
+
#
|
83
|
+
# @return data stored in the removed node
|
84
|
+
def remove_first
|
85
|
+
return nil if @list.empty?
|
86
|
+
@list.delete_at(head)
|
87
|
+
end
|
88
|
+
|
89
|
+
##
|
90
|
+
# Iterates over nodes from top to bottom passing node data to the block if
|
91
|
+
# given. If no block given, returns +Enumerator+.
|
92
|
+
#
|
93
|
+
# @returns +Enumerator+ or yields data to the block stored in every node on the
|
94
|
+
# list.
|
95
|
+
#
|
96
|
+
def each
|
97
|
+
return to_enum(__callee__) unless block_given?
|
98
|
+
__each { |node| yield(node.data) }
|
99
|
+
end
|
100
|
+
|
101
|
+
# Returns list array without list info.
|
102
|
+
#
|
103
|
+
def to_a
|
104
|
+
@list
|
105
|
+
end
|
106
|
+
alias_method :to_ary, :to_a
|
107
|
+
|
108
|
+
# Passing all missing methods to the list so all array operations can be performed.
|
109
|
+
def method_missing method_id, *args
|
110
|
+
# binding.pry
|
111
|
+
begin
|
112
|
+
return @list.send(method_id,*args)
|
113
|
+
rescue
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def inspect
|
119
|
+
sprintf('#<%s:%#x %s>', self.class, self.__id__, to_a.inspect)
|
120
|
+
end
|
121
|
+
|
122
|
+
# # Conversion function, see +Conversions.List+.
|
123
|
+
# #
|
124
|
+
# # == Returns:
|
125
|
+
# # +self+
|
126
|
+
# #
|
127
|
+
# def to_list
|
128
|
+
# self
|
129
|
+
# end
|
130
|
+
|
131
|
+
private
|
132
|
+
|
133
|
+
def head
|
134
|
+
@list && @list.size > 0 ? 0 : nil
|
135
|
+
end
|
136
|
+
|
137
|
+
def tail
|
138
|
+
@list && @list.size > 0 ? @list.size-1 : nil
|
139
|
+
end
|
140
|
+
|
141
|
+
def __each
|
142
|
+
curr_node = @head
|
143
|
+
while(curr_node)
|
144
|
+
yield curr_node
|
145
|
+
curr_node = curr_node.next
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,202 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'DoublyLinkedList' do
|
4
|
+
|
5
|
+
describe '#new' do
|
6
|
+
it "should initialize to empty list" do
|
7
|
+
l = DoublyLinkedList.new
|
8
|
+
expect(l.size).to eq 0
|
9
|
+
expect(l.first).to be_nil
|
10
|
+
expect(l.last).to be_nil
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should initialize with list info" do
|
14
|
+
l = DoublyLinkedList.new :list_info => {:title =>'test list', :description => 'Test out my doubly linked list.'}
|
15
|
+
expect(l.size).to eq 0
|
16
|
+
expect(l.first).to be_nil
|
17
|
+
expect(l.last).to be_nil
|
18
|
+
expect(l.list_info).to be_kind_of(Hash)
|
19
|
+
expect(l.list_info).to eq( {:title =>'test list', :description => 'Test out my doubly linked list.'} )
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should initialize with items" do
|
23
|
+
l = DoublyLinkedList.new :items => ['cat','dog','rabbit','fish']
|
24
|
+
expect(l.size).to eq 4
|
25
|
+
expect(l.first).to eq 'cat'
|
26
|
+
expect(l.last).to eq 'fish'
|
27
|
+
expect(l.to_a).to eq ['cat','dog','rabbit','fish']
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should initialize with list info and items" do
|
31
|
+
l = DoublyLinkedList.new :list_info => {:title =>'test list', :description => 'Test out my doubly linked list.'},
|
32
|
+
:items => ['cat','dog','rabbit','fish']
|
33
|
+
expect(l.size).to eq 4
|
34
|
+
expect(l.first).to eq 'cat'
|
35
|
+
expect(l.last).to eq 'fish'
|
36
|
+
expect(l.to_a).to eq ['cat','dog','rabbit','fish']
|
37
|
+
expect(l.list_info).to be_kind_of(Hash)
|
38
|
+
expect(l.list_info).to eq( {:title =>'test list', :description => 'Test out my doubly linked list.'} )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#add_last' do
|
43
|
+
it "should create list and add item when list is empty" do
|
44
|
+
l = DoublyLinkedList.new
|
45
|
+
expect(l.size).to eq 0
|
46
|
+
expect(l.first).to be_nil
|
47
|
+
expect(l.last).to be_nil
|
48
|
+
|
49
|
+
expect(l.add_last('cat')).to eq 1
|
50
|
+
expect(l.size).to eq 1
|
51
|
+
expect(l.first).to eq 'cat'
|
52
|
+
expect(l.last).to eq 'cat'
|
53
|
+
expect(l.to_a).to eq ['cat']
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should add item after last when one item list" do
|
57
|
+
l = DoublyLinkedList.new :items => ['dog']
|
58
|
+
expect(l.size).to eq 1
|
59
|
+
expect(l.first).to eq 'dog'
|
60
|
+
expect(l.last).to eq 'dog'
|
61
|
+
|
62
|
+
expect(l.add_last('cat')).to eq 2
|
63
|
+
expect(l.size).to eq 2
|
64
|
+
expect(l.first).to eq 'dog'
|
65
|
+
expect(l.last).to eq 'cat'
|
66
|
+
expect(l.to_a).to eq ['dog','cat']
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should add item after last when multiple item list" do
|
70
|
+
l = DoublyLinkedList.new :items => ['cat','dog','rabbit','fish']
|
71
|
+
expect(l.size).to eq 4
|
72
|
+
expect(l.first).to eq 'cat'
|
73
|
+
expect(l.last).to eq 'fish'
|
74
|
+
|
75
|
+
expect(l.add_last('gerbil')).to eq 5
|
76
|
+
expect(l.size).to eq 5
|
77
|
+
expect(l.first).to eq 'cat'
|
78
|
+
expect(l.last).to eq 'gerbil'
|
79
|
+
expect(l.to_a).to eq ['cat','dog','rabbit','fish','gerbil']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#add_first' do
|
84
|
+
it "should create list and add item when list is empty" do
|
85
|
+
l = DoublyLinkedList.new
|
86
|
+
expect(l.size).to eq 0
|
87
|
+
expect(l.first).to be_nil
|
88
|
+
expect(l.last).to be_nil
|
89
|
+
|
90
|
+
expect(l.add_first('cat')).to eq 1
|
91
|
+
expect(l.size).to eq 1
|
92
|
+
expect(l.first).to eq 'cat'
|
93
|
+
expect(l.last).to eq 'cat'
|
94
|
+
expect(l.to_a).to eq ['cat']
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should add item before first when one item list" do
|
98
|
+
l = DoublyLinkedList.new :items => ['dog']
|
99
|
+
expect(l.size).to eq 1
|
100
|
+
expect(l.first).to eq 'dog'
|
101
|
+
expect(l.last).to eq 'dog'
|
102
|
+
|
103
|
+
expect(l.add_first('cat')).to eq 2
|
104
|
+
expect(l.size).to eq 2
|
105
|
+
expect(l.first).to eq 'cat'
|
106
|
+
expect(l.last).to eq 'dog'
|
107
|
+
expect(l.to_a).to eq ['cat','dog']
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should add item before first when multiple item list" do
|
111
|
+
l = DoublyLinkedList.new :items => ['cat','dog','rabbit','fish']
|
112
|
+
expect(l.size).to eq 4
|
113
|
+
expect(l.first).to eq 'cat'
|
114
|
+
expect(l.last).to eq 'fish'
|
115
|
+
|
116
|
+
expect(l.add_first('gerbil')).to eq 5
|
117
|
+
expect(l.size).to eq 5
|
118
|
+
expect(l.first).to eq 'gerbil'
|
119
|
+
expect(l.last).to eq 'fish'
|
120
|
+
expect(l.to_a).to eq ['gerbil','cat','dog','rabbit','fish']
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe '#remove_last' do
|
125
|
+
it "should return nil when list is empty" do
|
126
|
+
l = DoublyLinkedList.new
|
127
|
+
expect(l.size).to eq 0
|
128
|
+
expect(l.first).to be_nil
|
129
|
+
expect(l.last).to be_nil
|
130
|
+
|
131
|
+
expect(l.remove_last).to be_nil
|
132
|
+
expect(l.size).to eq 0
|
133
|
+
expect(l.first).to be_nil
|
134
|
+
expect(l.last).to be_nil
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should remove item emptying the list and return item's data when one item list" do
|
138
|
+
l = DoublyLinkedList.new :items => ['dog']
|
139
|
+
expect(l.size).to eq 1
|
140
|
+
expect(l.first).to eq 'dog'
|
141
|
+
expect(l.last).to eq 'dog'
|
142
|
+
|
143
|
+
expect(l.remove_last).to eq 'dog'
|
144
|
+
expect(l.size).to eq 0
|
145
|
+
expect(l.first).to be_nil
|
146
|
+
expect(l.last).to be_nil
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should add item before first when multiple item list" do
|
150
|
+
l = DoublyLinkedList.new :items => ['cat','dog','rabbit','fish']
|
151
|
+
expect(l.size).to eq 4
|
152
|
+
expect(l.first).to eq 'cat'
|
153
|
+
expect(l.last).to eq 'fish'
|
154
|
+
|
155
|
+
expect(l.remove_last).to eq 'fish'
|
156
|
+
expect(l.size).to eq 3
|
157
|
+
expect(l.first).to eq 'cat'
|
158
|
+
expect(l.last).to eq 'rabbit'
|
159
|
+
expect(l.to_a).to eq ['cat','dog','rabbit']
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#remove_first' do
|
164
|
+
it "should return nil when list is empty" do
|
165
|
+
l = DoublyLinkedList.new
|
166
|
+
expect(l.size).to eq 0
|
167
|
+
expect(l.first).to be_nil
|
168
|
+
expect(l.last).to be_nil
|
169
|
+
|
170
|
+
expect(l.remove_first).to be_nil
|
171
|
+
expect(l.size).to eq 0
|
172
|
+
expect(l.first).to be_nil
|
173
|
+
expect(l.last).to be_nil
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should remove item emptying the list and return item's data when one item list" do
|
177
|
+
l = DoublyLinkedList.new :items => ['dog']
|
178
|
+
expect(l.size).to eq 1
|
179
|
+
expect(l.first).to eq 'dog'
|
180
|
+
expect(l.last).to eq 'dog'
|
181
|
+
|
182
|
+
expect(l.remove_first).to eq 'dog'
|
183
|
+
expect(l.size).to eq 0
|
184
|
+
expect(l.first).to be_nil
|
185
|
+
expect(l.last).to be_nil
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should add item before first when multiple item list" do
|
189
|
+
l = DoublyLinkedList.new :items => ['cat','dog','rabbit','fish']
|
190
|
+
expect(l.size).to eq 4
|
191
|
+
expect(l.first).to eq 'cat'
|
192
|
+
expect(l.last).to eq 'fish'
|
193
|
+
|
194
|
+
expect(l.remove_first).to eq 'cat'
|
195
|
+
expect(l.size).to eq 3
|
196
|
+
expect(l.first).to eq 'dog'
|
197
|
+
expect(l.last).to eq 'fish'
|
198
|
+
expect(l.to_a).to eq ['dog','rabbit','fish']
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'coveralls'
|
2
|
+
Coveralls.wear!
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
Bundler.setup
|
6
|
+
|
7
|
+
require 'pry'
|
8
|
+
require 'doubly_linked_list'
|
9
|
+
|
10
|
+
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.color = true
|
14
|
+
config.tty = true
|
15
|
+
|
16
|
+
# Uncomment the following line to get errors and backtrace for deprecation warnings
|
17
|
+
# config.raise_errors_for_deprecations!
|
18
|
+
|
19
|
+
# Use the specified formatter
|
20
|
+
config.formatter = :progress
|
21
|
+
end
|
22
|
+
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doubly_linked_list
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- E. Lynette Rayle
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry-byebug
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Ruby implementation of doubly_linked_lists using an array to hold and
|
84
|
+
manipulate items.
|
85
|
+
email:
|
86
|
+
- elr37@cornell.edu
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files:
|
90
|
+
- LICENSE.txt
|
91
|
+
- README.md
|
92
|
+
files:
|
93
|
+
- ".coveralls.yml"
|
94
|
+
- ".gitignore"
|
95
|
+
- ".travis.yml"
|
96
|
+
- Gemfile
|
97
|
+
- LICENSE.txt
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- doubly_linked_list.gemspec
|
101
|
+
- lib/doubly_linked_list.rb
|
102
|
+
- spec/doubly_linked_list_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/elrayle/doubly_linked_list
|
105
|
+
licenses:
|
106
|
+
- APACHE2
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.9.3
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Ruby implementation of doubly_linked_lists using an array to hold and manipulate
|
128
|
+
items.
|
129
|
+
test_files:
|
130
|
+
- spec/doubly_linked_list_spec.rb
|
131
|
+
- spec/spec_helper.rb
|