foodAX 3.3.0
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 +12 -0
- data/.travis.yml +6 -0
- data/Gemfile +6 -0
- data/Guardfile +82 -0
- data/LICENSE.txt +21 -0
- data/README.md +70 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/DLLModule.html +126 -0
- data/docs/DLLModule/DLL.html +1185 -0
- data/docs/DLLModule/Node.html +409 -0
- data/docs/Food.html +567 -0
- data/docs/FoodAbstract.html +807 -0
- data/docs/FoodGem.html +156 -0
- data/docs/_config.yml +1 -0
- data/docs/_index.html +154 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +161 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +161 -0
- data/docs/input/dish_recipes.txt +18 -0
- data/docs/input/food-data.txt +19 -0
- data/docs/input/samples-data.txt +9 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +267 -0
- data/docs/top-level-namespace.html +297 -0
- data/food.gemspec +45 -0
- data/input/dish_recipes.txt +18 -0
- data/input/food-data.txt +19 -0
- data/input/samples-data.txt +9 -0
- data/lib/dsl/harvard_dish.rb +123 -0
- data/lib/food.rb +12 -0
- data/lib/food/dll.rb +168 -0
- data/lib/food/food_class.rb +139 -0
- data/lib/food/functions.rb +144 -0
- data/lib/food/sort.rb +135 -0
- data/lib/food/version.rb +6 -0
- metadata +216 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 183ef1b764aed748bcc3a575fb223e2767f18cd6
|
4
|
+
data.tar.gz: 9c4b64d97a3b90041cf455f3efa0ea201480b986
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c619efd582224d6e39d176e85265f3b5fd864c1263532661602dd0bb0d54bfdf854d121ed399b5810e2846260df1b8cfc3723a250f6cd297d2278ec7a4b33fab
|
7
|
+
data.tar.gz: 39c6399cb156dfcfbcc708096b10b379780cf4609dc981962c3df29f6fb12a952b0a0f6c4c03817ac564f725cec2cb66c6c8191cae233690dc9374fde0037c64
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
guard :bundler do
|
19
|
+
require 'guard/bundler'
|
20
|
+
require 'guard/bundler/verify'
|
21
|
+
helper = Guard::Bundler::Verify.new
|
22
|
+
|
23
|
+
files = ['Gemfile']
|
24
|
+
files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
|
25
|
+
|
26
|
+
# Assume files are symlinked from somewhere
|
27
|
+
files.each { |file| watch(helper.real_path(file)) }
|
28
|
+
end
|
29
|
+
|
30
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
31
|
+
# rspec may be run, below are examples of the most common uses.
|
32
|
+
# * bundler: 'bundle exec rspec'
|
33
|
+
# * bundler binstubs: 'bin/rspec'
|
34
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
35
|
+
# installed the spring binstubs per the docs)
|
36
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
37
|
+
# * 'just' rspec: 'rspec'
|
38
|
+
|
39
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
40
|
+
require "guard/rspec/dsl"
|
41
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
42
|
+
|
43
|
+
# Feel free to open issues for suggestions and improvements
|
44
|
+
|
45
|
+
# RSpec files
|
46
|
+
rspec = dsl.rspec
|
47
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
48
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
49
|
+
watch(rspec.spec_files)
|
50
|
+
|
51
|
+
# Ruby files
|
52
|
+
ruby = dsl.ruby
|
53
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
54
|
+
|
55
|
+
# Rails files
|
56
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
57
|
+
dsl.watch_spec_files_for(rails.app_files)
|
58
|
+
dsl.watch_spec_files_for(rails.views)
|
59
|
+
|
60
|
+
watch(rails.controllers) do |m|
|
61
|
+
[
|
62
|
+
rspec.spec.call("routing/#{m[1]}_routing"),
|
63
|
+
rspec.spec.call("controllers/#{m[1]}_controller"),
|
64
|
+
rspec.spec.call("acceptance/#{m[1]}")
|
65
|
+
]
|
66
|
+
end
|
67
|
+
|
68
|
+
# Rails config changes
|
69
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
70
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
71
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
72
|
+
|
73
|
+
# Capybara features specs
|
74
|
+
watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
|
75
|
+
watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
|
76
|
+
|
77
|
+
# Turnip features and steps
|
78
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
79
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
80
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
81
|
+
end
|
82
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Angel Igareta
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Food
|
2
|
+
|
3
|
+
## Descipción del Proyecto
|
4
|
+
|
5
|
+
Para llevar a cabo todos los procesos que nos permiten estar vivos, el organismo humano necesita un
|
6
|
+
suministro continuo de materiales que debemos ingerir: **los nutrientes**. Sin embargo, estos nutrientes
|
7
|
+
no se ingieren directamente, sino que forman parte de los alimentos. Las multiples combinaciones en
|
8
|
+
que la naturaleza ofrece los diferentes nutrientes nos dan una amplia variedad de alimentos que el ser
|
9
|
+
humano puede consumir.
|
10
|
+
|
11
|
+
Se puede hacer una primera distinción entre los componentes de cualquier alimento en base a las
|
12
|
+
cantidades en que estan presentes: los llamados macronutrientes, que son los que ocupan la mayor
|
13
|
+
proporcion de los alimentos, y los llamados micronutrientes, que solo estan presentes en pequeñísimas
|
14
|
+
proporciones. Los macronutrientes son las proteínas, los glucidos (o hidratos de carbono) y los lípidos (o
|
15
|
+
grasas). Tambien se podría incluir a la fibra y al agua, que estan presentes en cantidades considerables
|
16
|
+
en la mayoría de los alimentos, pero como no aportan calorías no suelen considerarse nutrientes. Entre
|
17
|
+
los micronutrientes se encuentran las vitaminas y los minerales.
|
18
|
+
|
19
|
+
El **valor energetico o valor calorico** de un alimento es proporcional a la cantidad de energía que
|
20
|
+
puede proporcionar al quemarse en presencia de oxígeno. Se mide en calorías.Como su valor resulta
|
21
|
+
muy pequeño, en dietetica se toma como medida la kilocaloría (1 Kcal. = 1.000 calorías). Las dietas
|
22
|
+
de los humanos adultos contienen entre 1.000 y 5.000 kilocalorías por día.
|
23
|
+
|
24
|
+
Cada grupo de nutrientes energeticos: glucidos, lípidos o proteínas tiene un valor calórico diferente
|
25
|
+
y mas o menos uniforme en cada grupo. Para facilitar los calculos del valor energetico de los alimentos
|
26
|
+
se toman unos valores estandar para cada grupo:
|
27
|
+
|
28
|
+
+ Cuando el organismo quema 1 g de glucidos obtiene 4 Kcal
|
29
|
+
+ Cuando el organismo quema 1 g de lípidos obtiene 9 Kcal
|
30
|
+
+ Cuando el organismo quema 1 g de proteínas consigue 4 Kcal
|
31
|
+
|
32
|
+
De ahí que los alimentos ricos en grasa tengan un contenido energetico mucho mayor que los formados
|
33
|
+
por glucidos o proteínas. Las vitaminas y los minerales, así como los oligoelementos, el agua y la fibra
|
34
|
+
se considera que no aportan calorías.
|
35
|
+
|
36
|
+
Por ejemplo, un alimento que contenga 10 g de proteína, 20 g
|
37
|
+
de glucidos y 9 g de grasa nos proporcionaría 201 Kcal: 10 × 4 + 20 × 4 + 9 × 9 = 201Kcal
|
38
|
+
|
39
|
+
---
|
40
|
+
## Requisitos
|
41
|
+
|
42
|
+
+ Debe existir un nombre para el alimento.
|
43
|
+
+ Debe existir la candidad de proteínas del alimento en gramos.
|
44
|
+
+ Debe existir la candidad de glúcidos del alimento en gramos.
|
45
|
+
+ Debe existir la candidad de grasas del alimento en gramos.
|
46
|
+
+ Existe un método para obtener el nombre del alimento.
|
47
|
+
+ Existe un método para obtener la cantidad de proteínas de un alimento.
|
48
|
+
+ Existe un método para obtener la cantidad de glúcidos de un alimento.
|
49
|
+
+ Existe un método para obtener de grasas de un alimento.
|
50
|
+
+ Existe un método para obtener el alimento formateado.
|
51
|
+
+ Existe un método para obtener el valor energético de un alimento.
|
52
|
+
|
53
|
+
---
|
54
|
+
|
55
|
+
## Resultado
|
56
|
+
|
57
|
+
### El resultado de la práctica debe ser una clase Alimento que contenga:
|
58
|
+
|
59
|
+
| Alimento | Proteínas | Glúcidos | Lípidos |
|
60
|
+
| -------------|:----------:|:----------:|:---------:|
|
61
|
+
| Huevo frito | 14.1 | 0.0 | 19.5 |
|
62
|
+
| Leche vaca | 3.3 | 4.8 | 3.2 |
|
63
|
+
| Yogurt | 3.8 | 4.9 | 3.8 |
|
64
|
+
| Cerdo | 21.5 | 0.0 | 6.3 |
|
65
|
+
|
66
|
+
|
67
|
+
---
|
68
|
+
## Licencia
|
69
|
+
|
70
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "food"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docs/DLLModule.html
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: DLLModule
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "DLLModule";
|
19
|
+
relpath = '';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="_index.html">Index (D)</a> »
|
40
|
+
|
41
|
+
|
42
|
+
<span class="title">DLLModule</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: DLLModule
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/food/dll.rb</dd>
|
82
|
+
</dl>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<h2>Overview</h2><div class="docstring">
|
87
|
+
<div class="discussion">
|
88
|
+
|
89
|
+
<p>Class Doubly Linked List</p>
|
90
|
+
|
91
|
+
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
<div class="tags">
|
95
|
+
|
96
|
+
|
97
|
+
</div><h2>Defined Under Namespace</h2>
|
98
|
+
<p class="children">
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="DLLModule/DLL.html" title="DLLModule::DLL (class)">DLL</a></span>, <span class='object_link'><a href="DLLModule/Node.html" title="DLLModule::Node (class)">Node</a></span>
|
104
|
+
|
105
|
+
|
106
|
+
</p>
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
|
118
|
+
<div id="footer">
|
119
|
+
Generated on Wed Nov 15 11:48:20 2017 by
|
120
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
|
+
0.9.9 (ruby-2.3.0).
|
122
|
+
</div>
|
123
|
+
|
124
|
+
</div>
|
125
|
+
</body>
|
126
|
+
</html>
|
@@ -0,0 +1,1185 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: DLLModule::DLL
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "DLLModule::DLL";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (D)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../DLLModule.html" title="DLLModule (module)">DLLModule</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">DLL</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: DLLModule::DLL
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">DLLModule::DLL</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
<dl>
|
91
|
+
<dt>Includes:</dt>
|
92
|
+
<dd>Enumerable</dd>
|
93
|
+
</dl>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
<dl>
|
101
|
+
<dt>Defined in:</dt>
|
102
|
+
<dd>lib/food/dll.rb</dd>
|
103
|
+
</dl>
|
104
|
+
|
105
|
+
</div>
|
106
|
+
|
107
|
+
<h2>Overview</h2><div class="docstring">
|
108
|
+
<div class="discussion">
|
109
|
+
|
110
|
+
<p>Class Doubly Linked List</p>
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
</div>
|
115
|
+
<div class="tags">
|
116
|
+
|
117
|
+
|
118
|
+
</div>
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
123
|
+
<ul class="summary">
|
124
|
+
|
125
|
+
<li class="public ">
|
126
|
+
<span class="summary_signature">
|
127
|
+
|
128
|
+
<a href="#size-instance_method" title="#size (instance method)">#<strong>size</strong> ⇒ Object </a>
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
</span>
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<span class="note title readonly">readonly</span>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<h2>
|
159
|
+
Instance Method Summary
|
160
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
161
|
+
</h2>
|
162
|
+
|
163
|
+
<ul class="summary">
|
164
|
+
|
165
|
+
<li class="public ">
|
166
|
+
<span class="summary_signature">
|
167
|
+
|
168
|
+
<a href="#delete-instance_method" title="#delete (instance method)">#<strong>delete</strong>(value) ⇒ Object </a>
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
</span>
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
<span class="summary_desc"><div class='inline'>
|
183
|
+
<p>Delete an specific element in DLL head.</p>
|
184
|
+
</div></span>
|
185
|
+
|
186
|
+
</li>
|
187
|
+
|
188
|
+
|
189
|
+
<li class="public ">
|
190
|
+
<span class="summary_signature">
|
191
|
+
|
192
|
+
<a href="#each-instance_method" title="#each (instance method)">#<strong>each</strong> ⇒ Object </a>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
</span>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<span class="summary_desc"><div class='inline'>
|
207
|
+
<p>Essential method for Enumerable.</p>
|
208
|
+
</div></span>
|
209
|
+
|
210
|
+
</li>
|
211
|
+
|
212
|
+
|
213
|
+
<li class="public ">
|
214
|
+
<span class="summary_signature">
|
215
|
+
|
216
|
+
<a href="#empty%3F-instance_method" title="#empty? (instance method)">#<strong>empty?</strong> ⇒ Boolean </a>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
</span>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
<span class="summary_desc"><div class='inline'>
|
231
|
+
<p>Return if DLL is empty.</p>
|
232
|
+
</div></span>
|
233
|
+
|
234
|
+
</li>
|
235
|
+
|
236
|
+
|
237
|
+
<li class="public ">
|
238
|
+
<span class="summary_signature">
|
239
|
+
|
240
|
+
<a href="#extract_head-instance_method" title="#extract_head (instance method)">#<strong>extract_head</strong> ⇒ Node </a>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
</span>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<span class="summary_desc"><div class='inline'>
|
255
|
+
<p>Extract element in DLL head.</p>
|
256
|
+
</div></span>
|
257
|
+
|
258
|
+
</li>
|
259
|
+
|
260
|
+
|
261
|
+
<li class="public ">
|
262
|
+
<span class="summary_signature">
|
263
|
+
|
264
|
+
<a href="#extract_tail-instance_method" title="#extract_tail (instance method)">#<strong>extract_tail</strong> ⇒ Node </a>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
</span>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<span class="summary_desc"><div class='inline'>
|
279
|
+
<p>Extract element in DLL tail.</p>
|
280
|
+
</div></span>
|
281
|
+
|
282
|
+
</li>
|
283
|
+
|
284
|
+
|
285
|
+
<li class="public ">
|
286
|
+
<span class="summary_signature">
|
287
|
+
|
288
|
+
<a href="#get_head-instance_method" title="#get_head (instance method)">#<strong>get_head</strong> ⇒ head(#value) </a>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
</span>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
<span class="summary_desc"><div class='inline'>
|
303
|
+
<p>Return head value.</p>
|
304
|
+
</div></span>
|
305
|
+
|
306
|
+
</li>
|
307
|
+
|
308
|
+
|
309
|
+
<li class="public ">
|
310
|
+
<span class="summary_signature">
|
311
|
+
|
312
|
+
<a href="#get_tail-instance_method" title="#get_tail (instance method)">#<strong>get_tail</strong> ⇒ tail(#value) </a>
|
313
|
+
|
314
|
+
|
315
|
+
|
316
|
+
</span>
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
<span class="summary_desc"><div class='inline'>
|
327
|
+
<p>Return tail value.</p>
|
328
|
+
</div></span>
|
329
|
+
|
330
|
+
</li>
|
331
|
+
|
332
|
+
|
333
|
+
<li class="public ">
|
334
|
+
<span class="summary_signature">
|
335
|
+
|
336
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(value = nil) ⇒ DLL </a>
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
</span>
|
341
|
+
|
342
|
+
|
343
|
+
<span class="note title constructor">constructor</span>
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
<span class="summary_desc"><div class='inline'>
|
353
|
+
<p>Constructor of DLL.</p>
|
354
|
+
</div></span>
|
355
|
+
|
356
|
+
</li>
|
357
|
+
|
358
|
+
|
359
|
+
<li class="public ">
|
360
|
+
<span class="summary_signature">
|
361
|
+
|
362
|
+
<a href="#insert_head-instance_method" title="#insert_head (instance method)">#<strong>insert_head</strong>(*value_array) ⇒ Object </a>
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
</span>
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
<span class="summary_desc"><div class='inline'>
|
377
|
+
<p>Insert element in DLL head.</p>
|
378
|
+
</div></span>
|
379
|
+
|
380
|
+
</li>
|
381
|
+
|
382
|
+
|
383
|
+
<li class="public ">
|
384
|
+
<span class="summary_signature">
|
385
|
+
|
386
|
+
<a href="#insert_tail-instance_method" title="#insert_tail (instance method)">#<strong>insert_tail</strong>(*value_array) ⇒ Object </a>
|
387
|
+
|
388
|
+
|
389
|
+
|
390
|
+
</span>
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
<span class="summary_desc"><div class='inline'>
|
401
|
+
<p>Insert element in DLL tail.</p>
|
402
|
+
</div></span>
|
403
|
+
|
404
|
+
</li>
|
405
|
+
|
406
|
+
|
407
|
+
</ul>
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
<div id="constructor_details" class="method_details_list">
|
412
|
+
<h2>Constructor Details</h2>
|
413
|
+
|
414
|
+
<div class="method_details first">
|
415
|
+
<h3 class="signature first" id="initialize-instance_method">
|
416
|
+
|
417
|
+
#<strong>initialize</strong>(value = nil) ⇒ <tt><span class='object_link'><a href="" title="DLLModule::DLL (class)">DLL</a></span></tt>
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
</h3><div class="docstring">
|
424
|
+
<div class="discussion">
|
425
|
+
|
426
|
+
<p>Constructor of DLL</p>
|
427
|
+
|
428
|
+
|
429
|
+
</div>
|
430
|
+
</div>
|
431
|
+
<div class="tags">
|
432
|
+
<p class="tag_title">Parameters:</p>
|
433
|
+
<ul class="param">
|
434
|
+
|
435
|
+
<li>
|
436
|
+
|
437
|
+
<span class='name'>value</span>
|
438
|
+
|
439
|
+
|
440
|
+
<span class='type'></span>
|
441
|
+
|
442
|
+
|
443
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
444
|
+
|
445
|
+
|
446
|
+
—
|
447
|
+
<div class='inline'>
|
448
|
+
<p>of Node</p>
|
449
|
+
</div>
|
450
|
+
|
451
|
+
</li>
|
452
|
+
|
453
|
+
<li>
|
454
|
+
|
455
|
+
<span class='name'>head</span>
|
456
|
+
|
457
|
+
|
458
|
+
<span class='type'>(<tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>)</span>
|
459
|
+
|
460
|
+
|
461
|
+
|
462
|
+
—
|
463
|
+
<div class='inline'>
|
464
|
+
<p>Head of the DLL</p>
|
465
|
+
</div>
|
466
|
+
|
467
|
+
</li>
|
468
|
+
|
469
|
+
<li>
|
470
|
+
|
471
|
+
<span class='name'>tail</span>
|
472
|
+
|
473
|
+
|
474
|
+
<span class='type'>(<tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>)</span>
|
475
|
+
|
476
|
+
|
477
|
+
|
478
|
+
—
|
479
|
+
<div class='inline'>
|
480
|
+
<p>Tail of the DLL</p>
|
481
|
+
</div>
|
482
|
+
|
483
|
+
</li>
|
484
|
+
|
485
|
+
<li>
|
486
|
+
|
487
|
+
<span class='name'>size</span>
|
488
|
+
|
489
|
+
|
490
|
+
<span class='type'>(<tt>int</tt>)</span>
|
491
|
+
|
492
|
+
|
493
|
+
|
494
|
+
—
|
495
|
+
<div class='inline'>
|
496
|
+
<p>size of the doubly linked list</p>
|
497
|
+
</div>
|
498
|
+
|
499
|
+
</li>
|
500
|
+
|
501
|
+
</ul>
|
502
|
+
|
503
|
+
|
504
|
+
</div><table class="source_code">
|
505
|
+
<tr>
|
506
|
+
<td>
|
507
|
+
<pre class="lines">
|
508
|
+
|
509
|
+
|
510
|
+
23
|
511
|
+
24
|
512
|
+
25
|
513
|
+
26
|
514
|
+
27
|
515
|
+
28
|
516
|
+
29</pre>
|
517
|
+
</td>
|
518
|
+
<td>
|
519
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 23</span>
|
520
|
+
|
521
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
522
|
+
<span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
523
|
+
|
524
|
+
<span class='ivar'>@head</span> <span class='op'>=</span> <span class='id identifier rubyid_node'>node</span>
|
525
|
+
<span class='ivar'>@tail</span> <span class='op'>=</span> <span class='id identifier rubyid_node'>node</span>
|
526
|
+
<span class='ivar'>@size</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='int'>0</span> <span class='op'>:</span> <span class='int'>1</span>
|
527
|
+
<span class='kw'>end</span></pre>
|
528
|
+
</td>
|
529
|
+
</tr>
|
530
|
+
</table>
|
531
|
+
</div>
|
532
|
+
|
533
|
+
</div>
|
534
|
+
|
535
|
+
<div id="instance_attr_details" class="attr_details">
|
536
|
+
<h2>Instance Attribute Details</h2>
|
537
|
+
|
538
|
+
|
539
|
+
<span id=""></span>
|
540
|
+
<div class="method_details first">
|
541
|
+
<h3 class="signature first" id="size-instance_method">
|
542
|
+
|
543
|
+
#<strong>size</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
544
|
+
|
545
|
+
|
546
|
+
|
547
|
+
|
548
|
+
|
549
|
+
</h3><table class="source_code">
|
550
|
+
<tr>
|
551
|
+
<td>
|
552
|
+
<pre class="lines">
|
553
|
+
|
554
|
+
|
555
|
+
16
|
556
|
+
17
|
557
|
+
18</pre>
|
558
|
+
</td>
|
559
|
+
<td>
|
560
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 16</span>
|
561
|
+
|
562
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_size'>size</span>
|
563
|
+
<span class='ivar'>@size</span>
|
564
|
+
<span class='kw'>end</span></pre>
|
565
|
+
</td>
|
566
|
+
</tr>
|
567
|
+
</table>
|
568
|
+
</div>
|
569
|
+
|
570
|
+
</div>
|
571
|
+
|
572
|
+
|
573
|
+
<div id="instance_method_details" class="method_details_list">
|
574
|
+
<h2>Instance Method Details</h2>
|
575
|
+
|
576
|
+
|
577
|
+
<div class="method_details first">
|
578
|
+
<h3 class="signature first" id="delete-instance_method">
|
579
|
+
|
580
|
+
#<strong>delete</strong>(value) ⇒ <tt>Object</tt>
|
581
|
+
|
582
|
+
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
</h3><div class="docstring">
|
587
|
+
<div class="discussion">
|
588
|
+
|
589
|
+
<p>Delete an specific element in DLL head</p>
|
590
|
+
|
591
|
+
|
592
|
+
</div>
|
593
|
+
</div>
|
594
|
+
<div class="tags">
|
595
|
+
|
596
|
+
|
597
|
+
</div><table class="source_code">
|
598
|
+
<tr>
|
599
|
+
<td>
|
600
|
+
<pre class="lines">
|
601
|
+
|
602
|
+
|
603
|
+
88
|
604
|
+
89
|
605
|
+
90
|
606
|
+
91
|
607
|
+
92
|
608
|
+
93
|
609
|
+
94
|
610
|
+
95
|
611
|
+
96
|
612
|
+
97
|
613
|
+
98
|
614
|
+
99
|
615
|
+
100
|
616
|
+
101
|
617
|
+
102
|
618
|
+
103
|
619
|
+
104
|
620
|
+
105
|
621
|
+
106
|
622
|
+
107
|
623
|
+
108
|
624
|
+
109
|
625
|
+
110
|
626
|
+
111</pre>
|
627
|
+
</td>
|
628
|
+
<td>
|
629
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 88</span>
|
630
|
+
|
631
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_delete'>delete</span> <span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
632
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='ivar'>@head</span>
|
633
|
+
|
634
|
+
<span class='kw'>while</span> <span class='op'>!</span><span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
635
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>==</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
636
|
+
<span class='kw'>if</span> <span class='lparen'>(</span><span class='ivar'>@size</span> <span class='op'>==</span> <span class='int'>1</span><span class='rparen'>)</span>
|
637
|
+
<span class='ivar'>@head</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
638
|
+
<span class='ivar'>@tail</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
639
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
640
|
+
<span class='kw'>else</span>
|
641
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>!=</span> <span class='ivar'>@head</span>
|
642
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span> <span class='op'>=</span> <span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
643
|
+
<span class='kw'>end</span>
|
644
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>!=</span> <span class='ivar'>@tail</span>
|
645
|
+
<span class='lparen'>(</span><span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span> <span class='op'>=</span> <span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span>
|
646
|
+
<span class='kw'>end</span>
|
647
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
648
|
+
<span class='kw'>end</span>
|
649
|
+
<span class='ivar'>@size</span> <span class='op'>-=</span> <span class='int'>1</span>
|
650
|
+
<span class='kw'>else</span>
|
651
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
652
|
+
<span class='kw'>end</span>
|
653
|
+
<span class='kw'>end</span>
|
654
|
+
<span class='kw'>end</span></pre>
|
655
|
+
</td>
|
656
|
+
</tr>
|
657
|
+
</table>
|
658
|
+
</div>
|
659
|
+
|
660
|
+
<div class="method_details ">
|
661
|
+
<h3 class="signature " id="each-instance_method">
|
662
|
+
|
663
|
+
#<strong>each</strong> ⇒ <tt>Object</tt>
|
664
|
+
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
</h3><div class="docstring">
|
670
|
+
<div class="discussion">
|
671
|
+
|
672
|
+
<p>Essential method for Enumerable</p>
|
673
|
+
|
674
|
+
|
675
|
+
</div>
|
676
|
+
</div>
|
677
|
+
<div class="tags">
|
678
|
+
|
679
|
+
|
680
|
+
</div><table class="source_code">
|
681
|
+
<tr>
|
682
|
+
<td>
|
683
|
+
<pre class="lines">
|
684
|
+
|
685
|
+
|
686
|
+
131
|
687
|
+
132
|
688
|
+
133
|
689
|
+
134
|
690
|
+
135
|
691
|
+
136
|
692
|
+
137
|
693
|
+
138</pre>
|
694
|
+
</td>
|
695
|
+
<td>
|
696
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 131</span>
|
697
|
+
|
698
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_each'>each</span>
|
699
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='ivar'>@head</span>
|
700
|
+
|
701
|
+
<span class='kw'>while</span> <span class='op'>!</span><span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
702
|
+
<span class='kw'>yield</span> <span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
703
|
+
<span class='id identifier rubyid_current_node'>current_node</span> <span class='op'>=</span> <span class='id identifier rubyid_current_node'>current_node</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
704
|
+
<span class='kw'>end</span>
|
705
|
+
<span class='kw'>end</span></pre>
|
706
|
+
</td>
|
707
|
+
</tr>
|
708
|
+
</table>
|
709
|
+
</div>
|
710
|
+
|
711
|
+
<div class="method_details ">
|
712
|
+
<h3 class="signature " id="empty?-instance_method">
|
713
|
+
|
714
|
+
#<strong>empty?</strong> ⇒ <tt>Boolean</tt>
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
</h3><div class="docstring">
|
721
|
+
<div class="discussion">
|
722
|
+
|
723
|
+
<p>Return if DLL is empty</p>
|
724
|
+
|
725
|
+
|
726
|
+
</div>
|
727
|
+
</div>
|
728
|
+
<div class="tags">
|
729
|
+
|
730
|
+
<p class="tag_title">Returns:</p>
|
731
|
+
<ul class="return">
|
732
|
+
|
733
|
+
<li>
|
734
|
+
|
735
|
+
|
736
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
737
|
+
|
738
|
+
|
739
|
+
|
740
|
+
</li>
|
741
|
+
|
742
|
+
</ul>
|
743
|
+
|
744
|
+
</div><table class="source_code">
|
745
|
+
<tr>
|
746
|
+
<td>
|
747
|
+
<pre class="lines">
|
748
|
+
|
749
|
+
|
750
|
+
126
|
751
|
+
127
|
752
|
+
128</pre>
|
753
|
+
</td>
|
754
|
+
<td>
|
755
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 126</span>
|
756
|
+
|
757
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_empty?'>empty?</span>
|
758
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_size'>size</span> <span class='op'>==</span> <span class='int'>0</span>
|
759
|
+
<span class='kw'>end</span></pre>
|
760
|
+
</td>
|
761
|
+
</tr>
|
762
|
+
</table>
|
763
|
+
</div>
|
764
|
+
|
765
|
+
<div class="method_details ">
|
766
|
+
<h3 class="signature " id="extract_head-instance_method">
|
767
|
+
|
768
|
+
#<strong>extract_head</strong> ⇒ <tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
|
774
|
+
</h3><div class="docstring">
|
775
|
+
<div class="discussion">
|
776
|
+
|
777
|
+
<p>Extract element in DLL head</p>
|
778
|
+
|
779
|
+
|
780
|
+
</div>
|
781
|
+
</div>
|
782
|
+
<div class="tags">
|
783
|
+
|
784
|
+
<p class="tag_title">Returns:</p>
|
785
|
+
<ul class="return">
|
786
|
+
|
787
|
+
<li>
|
788
|
+
|
789
|
+
|
790
|
+
<span class='type'>(<tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>)</span>
|
791
|
+
|
792
|
+
|
793
|
+
|
794
|
+
—
|
795
|
+
<div class='inline'>
|
796
|
+
<p>value of the node that was in the head</p>
|
797
|
+
</div>
|
798
|
+
|
799
|
+
</li>
|
800
|
+
|
801
|
+
</ul>
|
802
|
+
|
803
|
+
</div><table class="source_code">
|
804
|
+
<tr>
|
805
|
+
<td>
|
806
|
+
<pre class="lines">
|
807
|
+
|
808
|
+
|
809
|
+
53
|
810
|
+
54
|
811
|
+
55
|
812
|
+
56
|
813
|
+
57
|
814
|
+
58
|
815
|
+
59
|
816
|
+
60
|
817
|
+
61
|
818
|
+
62
|
819
|
+
63
|
820
|
+
64
|
821
|
+
65
|
822
|
+
66
|
823
|
+
67</pre>
|
824
|
+
</td>
|
825
|
+
<td>
|
826
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 53</span>
|
827
|
+
|
828
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extract_head'>extract_head</span>
|
829
|
+
<span class='kw'>if</span> <span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
830
|
+
<span class='kw'>return</span> <span class='kw'>nil</span>
|
831
|
+
<span class='kw'>else</span>
|
832
|
+
<span class='ivar'>@size</span> <span class='op'>-=</span> <span class='int'>1</span>
|
833
|
+
|
834
|
+
<span class='id identifier rubyid_node_to_return'>node_to_return</span> <span class='op'>=</span> <span class='ivar'>@head</span>
|
835
|
+
|
836
|
+
<span class='ivar'>@head</span> <span class='op'>=</span> <span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span>
|
837
|
+
<span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
838
|
+
|
839
|
+
<span class='id identifier rubyid_node_to_return'>node_to_return</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
840
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_node_to_return'>node_to_return</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
841
|
+
<span class='kw'>end</span>
|
842
|
+
<span class='kw'>end</span></pre>
|
843
|
+
</td>
|
844
|
+
</tr>
|
845
|
+
</table>
|
846
|
+
</div>
|
847
|
+
|
848
|
+
<div class="method_details ">
|
849
|
+
<h3 class="signature " id="extract_tail-instance_method">
|
850
|
+
|
851
|
+
#<strong>extract_tail</strong> ⇒ <tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>
|
852
|
+
|
853
|
+
|
854
|
+
|
855
|
+
|
856
|
+
|
857
|
+
</h3><div class="docstring">
|
858
|
+
<div class="discussion">
|
859
|
+
|
860
|
+
<p>Extract element in DLL tail</p>
|
861
|
+
|
862
|
+
|
863
|
+
</div>
|
864
|
+
</div>
|
865
|
+
<div class="tags">
|
866
|
+
|
867
|
+
<p class="tag_title">Returns:</p>
|
868
|
+
<ul class="return">
|
869
|
+
|
870
|
+
<li>
|
871
|
+
|
872
|
+
|
873
|
+
<span class='type'>(<tt><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></tt>)</span>
|
874
|
+
|
875
|
+
|
876
|
+
|
877
|
+
—
|
878
|
+
<div class='inline'>
|
879
|
+
<p>value of the node that was in the tail</p>
|
880
|
+
</div>
|
881
|
+
|
882
|
+
</li>
|
883
|
+
|
884
|
+
</ul>
|
885
|
+
|
886
|
+
</div><table class="source_code">
|
887
|
+
<tr>
|
888
|
+
<td>
|
889
|
+
<pre class="lines">
|
890
|
+
|
891
|
+
|
892
|
+
71
|
893
|
+
72
|
894
|
+
73
|
895
|
+
74
|
896
|
+
75
|
897
|
+
76
|
898
|
+
77
|
899
|
+
78
|
900
|
+
79
|
901
|
+
80
|
902
|
+
81
|
903
|
+
82
|
904
|
+
83
|
905
|
+
84
|
906
|
+
85</pre>
|
907
|
+
</td>
|
908
|
+
<td>
|
909
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 71</span>
|
910
|
+
|
911
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extract_tail'>extract_tail</span>
|
912
|
+
<span class='kw'>if</span> <span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
913
|
+
<span class='kw'>return</span> <span class='kw'>nil</span>
|
914
|
+
<span class='kw'>else</span>
|
915
|
+
<span class='ivar'>@size</span> <span class='op'>-=</span> <span class='int'>1</span>
|
916
|
+
|
917
|
+
<span class='id identifier rubyid_node_to_return'>node_to_return</span> <span class='op'>=</span> <span class='ivar'>@tail</span>
|
918
|
+
|
919
|
+
<span class='ivar'>@tail</span> <span class='op'>=</span> <span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span>
|
920
|
+
<span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_next'>next</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
921
|
+
|
922
|
+
<span class='id identifier rubyid_node_to_return'>node_to_return</span><span class='period'>.</span><span class='id identifier rubyid_prev'>prev</span> <span class='op'>=</span> <span class='kw'>nil</span>
|
923
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_node_to_return'>node_to_return</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
924
|
+
<span class='kw'>end</span>
|
925
|
+
<span class='kw'>end</span></pre>
|
926
|
+
</td>
|
927
|
+
</tr>
|
928
|
+
</table>
|
929
|
+
</div>
|
930
|
+
|
931
|
+
<div class="method_details ">
|
932
|
+
<h3 class="signature " id="get_head-instance_method">
|
933
|
+
|
934
|
+
#<strong>get_head</strong> ⇒ <tt>head(#value)</tt>
|
935
|
+
|
936
|
+
|
937
|
+
|
938
|
+
|
939
|
+
|
940
|
+
</h3><div class="docstring">
|
941
|
+
<div class="discussion">
|
942
|
+
|
943
|
+
<p>Return head value</p>
|
944
|
+
|
945
|
+
|
946
|
+
</div>
|
947
|
+
</div>
|
948
|
+
<div class="tags">
|
949
|
+
|
950
|
+
<p class="tag_title">Returns:</p>
|
951
|
+
<ul class="return">
|
952
|
+
|
953
|
+
<li>
|
954
|
+
|
955
|
+
|
956
|
+
<span class='type'>(<tt>head(#value)</tt>)</span>
|
957
|
+
|
958
|
+
|
959
|
+
|
960
|
+
</li>
|
961
|
+
|
962
|
+
</ul>
|
963
|
+
|
964
|
+
</div><table class="source_code">
|
965
|
+
<tr>
|
966
|
+
<td>
|
967
|
+
<pre class="lines">
|
968
|
+
|
969
|
+
|
970
|
+
115
|
971
|
+
116
|
972
|
+
117</pre>
|
973
|
+
</td>
|
974
|
+
<td>
|
975
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 115</span>
|
976
|
+
|
977
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_head'>get_head</span>
|
978
|
+
<span class='kw'>return</span> <span class='ivar'>@head</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
979
|
+
<span class='kw'>end</span></pre>
|
980
|
+
</td>
|
981
|
+
</tr>
|
982
|
+
</table>
|
983
|
+
</div>
|
984
|
+
|
985
|
+
<div class="method_details ">
|
986
|
+
<h3 class="signature " id="get_tail-instance_method">
|
987
|
+
|
988
|
+
#<strong>get_tail</strong> ⇒ <tt>tail(#value)</tt>
|
989
|
+
|
990
|
+
|
991
|
+
|
992
|
+
|
993
|
+
|
994
|
+
</h3><div class="docstring">
|
995
|
+
<div class="discussion">
|
996
|
+
|
997
|
+
<p>Return tail value</p>
|
998
|
+
|
999
|
+
|
1000
|
+
</div>
|
1001
|
+
</div>
|
1002
|
+
<div class="tags">
|
1003
|
+
|
1004
|
+
<p class="tag_title">Returns:</p>
|
1005
|
+
<ul class="return">
|
1006
|
+
|
1007
|
+
<li>
|
1008
|
+
|
1009
|
+
|
1010
|
+
<span class='type'>(<tt>tail(#value)</tt>)</span>
|
1011
|
+
|
1012
|
+
|
1013
|
+
|
1014
|
+
</li>
|
1015
|
+
|
1016
|
+
</ul>
|
1017
|
+
|
1018
|
+
</div><table class="source_code">
|
1019
|
+
<tr>
|
1020
|
+
<td>
|
1021
|
+
<pre class="lines">
|
1022
|
+
|
1023
|
+
|
1024
|
+
121
|
1025
|
+
122
|
1026
|
+
123</pre>
|
1027
|
+
</td>
|
1028
|
+
<td>
|
1029
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 121</span>
|
1030
|
+
|
1031
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get_tail'>get_tail</span>
|
1032
|
+
<span class='kw'>return</span> <span class='ivar'>@tail</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span>
|
1033
|
+
<span class='kw'>end</span></pre>
|
1034
|
+
</td>
|
1035
|
+
</tr>
|
1036
|
+
</table>
|
1037
|
+
</div>
|
1038
|
+
|
1039
|
+
<div class="method_details ">
|
1040
|
+
<h3 class="signature " id="insert_head-instance_method">
|
1041
|
+
|
1042
|
+
#<strong>insert_head</strong>(*value_array) ⇒ <tt>Object</tt>
|
1043
|
+
|
1044
|
+
|
1045
|
+
|
1046
|
+
|
1047
|
+
|
1048
|
+
</h3><div class="docstring">
|
1049
|
+
<div class="discussion">
|
1050
|
+
|
1051
|
+
<p>Insert element in DLL head</p>
|
1052
|
+
|
1053
|
+
|
1054
|
+
</div>
|
1055
|
+
</div>
|
1056
|
+
<div class="tags">
|
1057
|
+
<p class="tag_title">Parameters:</p>
|
1058
|
+
<ul class="param">
|
1059
|
+
|
1060
|
+
<li>
|
1061
|
+
|
1062
|
+
<span class='name'>*value_array</span>
|
1063
|
+
|
1064
|
+
|
1065
|
+
<span class='type'>(<tt>array</tt>)</span>
|
1066
|
+
|
1067
|
+
|
1068
|
+
|
1069
|
+
—
|
1070
|
+
<div class='inline'>
|
1071
|
+
<p>set of values</p>
|
1072
|
+
</div>
|
1073
|
+
|
1074
|
+
</li>
|
1075
|
+
|
1076
|
+
</ul>
|
1077
|
+
|
1078
|
+
|
1079
|
+
</div><table class="source_code">
|
1080
|
+
<tr>
|
1081
|
+
<td>
|
1082
|
+
<pre class="lines">
|
1083
|
+
|
1084
|
+
|
1085
|
+
35
|
1086
|
+
36
|
1087
|
+
37
|
1088
|
+
38
|
1089
|
+
39
|
1090
|
+
40</pre>
|
1091
|
+
</td>
|
1092
|
+
<td>
|
1093
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 35</span>
|
1094
|
+
|
1095
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_insert_head'>insert_head</span> <span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_value_array'>value_array</span><span class='rparen'>)</span>
|
1096
|
+
<span class='id identifier rubyid_value_array'>value_array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
1097
|
+
<span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1098
|
+
<span class='id identifier rubyid_insert_head_private'>insert_head_private</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span><span class='semicolon'>;</span>
|
1099
|
+
<span class='rbrace'>}</span>
|
1100
|
+
<span class='kw'>end</span></pre>
|
1101
|
+
</td>
|
1102
|
+
</tr>
|
1103
|
+
</table>
|
1104
|
+
</div>
|
1105
|
+
|
1106
|
+
<div class="method_details ">
|
1107
|
+
<h3 class="signature " id="insert_tail-instance_method">
|
1108
|
+
|
1109
|
+
#<strong>insert_tail</strong>(*value_array) ⇒ <tt>Object</tt>
|
1110
|
+
|
1111
|
+
|
1112
|
+
|
1113
|
+
|
1114
|
+
|
1115
|
+
</h3><div class="docstring">
|
1116
|
+
<div class="discussion">
|
1117
|
+
|
1118
|
+
<p>Insert element in DLL tail</p>
|
1119
|
+
|
1120
|
+
|
1121
|
+
</div>
|
1122
|
+
</div>
|
1123
|
+
<div class="tags">
|
1124
|
+
<p class="tag_title">Parameters:</p>
|
1125
|
+
<ul class="param">
|
1126
|
+
|
1127
|
+
<li>
|
1128
|
+
|
1129
|
+
<span class='name'>*value_array</span>
|
1130
|
+
|
1131
|
+
|
1132
|
+
<span class='type'>(<tt>array</tt>)</span>
|
1133
|
+
|
1134
|
+
|
1135
|
+
|
1136
|
+
—
|
1137
|
+
<div class='inline'>
|
1138
|
+
<p>set of values</p>
|
1139
|
+
</div>
|
1140
|
+
|
1141
|
+
</li>
|
1142
|
+
|
1143
|
+
</ul>
|
1144
|
+
|
1145
|
+
|
1146
|
+
</div><table class="source_code">
|
1147
|
+
<tr>
|
1148
|
+
<td>
|
1149
|
+
<pre class="lines">
|
1150
|
+
|
1151
|
+
|
1152
|
+
44
|
1153
|
+
45
|
1154
|
+
46
|
1155
|
+
47
|
1156
|
+
48
|
1157
|
+
49</pre>
|
1158
|
+
</td>
|
1159
|
+
<td>
|
1160
|
+
<pre class="code"><span class="info file"># File 'lib/food/dll.rb', line 44</span>
|
1161
|
+
|
1162
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_insert_tail'>insert_tail</span> <span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_value_array'>value_array</span><span class='rparen'>)</span>
|
1163
|
+
<span class='id identifier rubyid_value_array'>value_array</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_value'>value</span><span class='op'>|</span>
|
1164
|
+
<span class='id identifier rubyid_node'>node</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Node.html" title="DLLModule::Node (class)">Node</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
1165
|
+
<span class='id identifier rubyid_insert_tail_private'>insert_tail_private</span><span class='lparen'>(</span><span class='id identifier rubyid_node'>node</span><span class='rparen'>)</span><span class='semicolon'>;</span>
|
1166
|
+
<span class='rbrace'>}</span>
|
1167
|
+
<span class='kw'>end</span></pre>
|
1168
|
+
</td>
|
1169
|
+
</tr>
|
1170
|
+
</table>
|
1171
|
+
</div>
|
1172
|
+
|
1173
|
+
</div>
|
1174
|
+
|
1175
|
+
</div>
|
1176
|
+
|
1177
|
+
<div id="footer">
|
1178
|
+
Generated on Wed Nov 15 11:48:21 2017 by
|
1179
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1180
|
+
0.9.9 (ruby-2.3.0).
|
1181
|
+
</div>
|
1182
|
+
|
1183
|
+
</div>
|
1184
|
+
</body>
|
1185
|
+
</html>
|