rubytree 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/API-CHANGES.rdoc +51 -20
- data/Gemfile +5 -1
- data/Gemfile.lock +14 -13
- data/History.rdoc +110 -42
- data/LICENSE.md +37 -0
- data/README.md +276 -0
- data/Rakefile +53 -28
- data/TAGS +218 -0
- data/TODO.org +114 -42
- data/examples/example_basic.rb +53 -0
- data/lib/tree.rb +357 -529
- data/lib/tree/binarytree.rb +76 -36
- data/lib/tree/utils/camel_case_method_handler.rb +78 -0
- data/lib/tree/utils/json_converter.rb +125 -0
- data/lib/tree/utils/metrics_methods.rb +172 -0
- data/lib/tree/utils/tree_merge_handler.rb +118 -0
- data/lib/tree/utils/utils.rb +41 -0
- data/lib/tree/version.rb +3 -3
- data/test/test_binarytree.rb +46 -1
- data/test/test_subclassed_node.rb +70 -0
- data/test/test_thread_and_fiber.rb +88 -0
- data/test/test_tree.rb +209 -35
- metadata +85 -82
- data/.dir-locals.el +0 -5
- data/COPYING.rdoc +0 -32
- data/README.rdoc +0 -219
data/Rakefile
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
#
|
3
3
|
# Rakefile - This file is part of the RubyTree package.
|
4
4
|
#
|
5
|
-
# Copyright (c) 2006, 2007, 2009, 2010, 2011, 2012 Anupam Sengupta
|
5
|
+
# Copyright (c) 2006, 2007, 2009, 2010, 2011, 2012, 2013 Anupam Sengupta
|
6
6
|
#
|
7
7
|
# All rights reserved.
|
8
8
|
#
|
9
|
-
# Redistribution and use in source and binary forms, with or without
|
10
|
-
# are permitted provided that the following conditions are met:
|
9
|
+
# Redistribution and use in source and binary forms, with or without
|
10
|
+
# modification, are permitted provided that the following conditions are met:
|
11
11
|
#
|
12
12
|
# - Redistributions of source code must retain the above copyright notice, this
|
13
13
|
# list of conditions and the following disclaimer.
|
@@ -40,7 +40,7 @@ PKG_VER = GEM_SPEC.version
|
|
40
40
|
GEM_NAME = "#{PKG_NAME}-#{PKG_VER}.gem"
|
41
41
|
|
42
42
|
desc "Default Task (Run the tests)"
|
43
|
-
task :default => 'test:
|
43
|
+
task :default => 'test:unit'
|
44
44
|
|
45
45
|
desc "Display the current gem version"
|
46
46
|
task :version do
|
@@ -50,7 +50,7 @@ end
|
|
50
50
|
require 'rake/clean'
|
51
51
|
task :clean => 'gem:clobber_package'
|
52
52
|
CLEAN.include('coverage')
|
53
|
-
task :clobber => [:clean, 'doc:clobber_rdoc', 'doc:clobber_yard'
|
53
|
+
task :clobber => [:clean, 'doc:clobber_rdoc', 'doc:clobber_yard']
|
54
54
|
|
55
55
|
desc "Open an irb session preloaded with this library"
|
56
56
|
task :console do
|
@@ -58,20 +58,28 @@ task :console do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
namespace :doc do # ................................ Documentation
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
61
|
+
begin
|
62
|
+
gem 'rdoc', ">= 2.4.2" # To get around a stupid bug in Ruby 1.9.2 Rake.
|
63
|
+
require 'rdoc/task'
|
64
|
+
Rake::RDocTask.new do |rdoc|
|
65
|
+
rdoc.rdoc_dir = 'rdoc'
|
66
|
+
rdoc.title = "#{PKG_NAME}-#{PKG_VER}"
|
67
|
+
rdoc.main = 'README.rdoc'
|
68
|
+
rdoc.rdoc_files.include(GEM_SPEC.extra_rdoc_files)
|
69
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
70
|
+
end
|
71
|
+
rescue LoadError
|
72
|
+
# Oh well.
|
69
73
|
end
|
70
74
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
begin
|
76
|
+
require 'yard'
|
77
|
+
YARD::Rake::YardocTask.new do |t|
|
78
|
+
t.files = ['lib/**/*.rb', '-', GEM_SPEC.extra_rdoc_files]
|
79
|
+
t.options = ['--no-private', '--embed-mixins']
|
80
|
+
end
|
81
|
+
rescue LoadError
|
82
|
+
# Oh well.
|
75
83
|
end
|
76
84
|
|
77
85
|
desc "Remove YARD Documentation"
|
@@ -92,22 +100,39 @@ namespace :test do # ................................ Test related
|
|
92
100
|
test.verbose = false
|
93
101
|
end
|
94
102
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
103
|
+
desc "Run the examples"
|
104
|
+
Rake::TestTask.new(:examples) do |example|
|
105
|
+
example.libs << 'lib' << 'examples'
|
106
|
+
example.pattern = 'examples/**/example_*.rb'
|
107
|
+
example.verbose = true
|
108
|
+
example.warning = false
|
109
|
+
end
|
110
|
+
|
111
|
+
begin
|
112
|
+
require 'rcov/rcovtask'
|
113
|
+
Rcov::RcovTask.new(:rcov) do |t|
|
114
|
+
t.libs << "test"
|
115
|
+
t.test_files = FileList['test/**/test_*.rb']
|
116
|
+
t.verbose = true
|
117
|
+
t.rcov_opts << '--exclude /gems/,/Library/,/usr/,spec,lib/tasks'
|
118
|
+
end
|
119
|
+
rescue LoadError
|
120
|
+
# Oh well. Can't have everything.
|
101
121
|
end
|
102
122
|
|
103
123
|
end
|
104
124
|
|
105
|
-
namespace :tag do # ................................ Emacs Tags
|
106
|
-
|
107
|
-
|
108
|
-
|
125
|
+
namespace :tag do # ................................ Emacs Tags
|
126
|
+
begin
|
127
|
+
require 'rtagstask'
|
128
|
+
RTagsTask.new(:tags) do |rd|
|
129
|
+
rd.vi = false
|
130
|
+
CLEAN.include('TAGS')
|
131
|
+
end
|
132
|
+
rescue LoadError
|
133
|
+
# Oh well. Can't have everything.
|
109
134
|
end
|
110
|
-
end
|
135
|
+
end
|
111
136
|
|
112
137
|
namespace :gem do # ................................ Gem related
|
113
138
|
require 'rubygems/package_task'
|
data/TAGS
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
|
2
|
+
../.dir-locals.el,0
|
3
|
+
|
4
|
+
../examples/example_basic.rb,0
|
5
|
+
|
6
|
+
../lib/rubytree.rb,0
|
7
|
+
|
8
|
+
../lib/tree/binarytree.rb,544
|
9
|
+
module TreeTree43,1900
|
10
|
+
class BinaryTreeNode < TreeNodeBinaryTreeNode52,2207
|
11
|
+
def left_childleft_child62,2488
|
12
|
+
def right_childright_child74,2879
|
13
|
+
def is_left_child?is_left_child?83,3155
|
14
|
+
def is_right_child?is_right_child?93,3486
|
15
|
+
def add(child)add110,4143
|
16
|
+
def inordered_each(&block)inordered_each128,4662
|
17
|
+
def set_child_at(child, at_index)set_child_at159,5598
|
18
|
+
def left_child=(child)left_child=178,6266
|
19
|
+
def right_child=(child)right_child=190,6635
|
20
|
+
def swap_childrenswap_children195,6781
|
21
|
+
|
22
|
+
../lib/tree/tree_deps.rb,0
|
23
|
+
|
24
|
+
../lib/tree/utils/camel_case_method_handler.rb,271
|
25
|
+
module Tree::UtilsTree41,1848
|
26
|
+
module CamelCaseMethodHandlerCamelCaseMethodHandler44,2002
|
27
|
+
def self.included(base)included45,2034
|
28
|
+
def method_missing(meth, *args, &blk)method_missing49,2180
|
29
|
+
def to_snake_case(camel_cased_word)to_snake_case66,2792
|
30
|
+
|
31
|
+
../lib/tree/utils/json_converter.rb,263
|
32
|
+
module Tree::Utils::JSONConverterTree42,1899
|
33
|
+
def self.included(base)included44,1934
|
34
|
+
def as_json(options = {})as_json61,2385
|
35
|
+
def to_json(*a)to_json89,3093
|
36
|
+
module ClassMethodsClassMethods94,3243
|
37
|
+
def json_create(json_hash)json_create113,3956
|
38
|
+
|
39
|
+
../lib/tree/utils/metrics_methods.rb,451
|
40
|
+
module Tree::UtilsTree41,1833
|
41
|
+
module TreeMetricsHandlerTreeMetricsHandler43,1916
|
42
|
+
def self.included(base)included44,1944
|
43
|
+
def sizesize56,2311
|
44
|
+
def lengthlength67,2655
|
45
|
+
def node_heightnode_height80,3072
|
46
|
+
def node_depthnode_depth96,3683
|
47
|
+
def levellevel105,3869
|
48
|
+
def depthdepth124,4554
|
49
|
+
def breadthbreadth140,5191
|
50
|
+
def in_degreein_degree154,5654
|
51
|
+
def out_degreeout_degree165,5967
|
52
|
+
|
53
|
+
../lib/tree/utils/tree_merge_handler.rb,259
|
54
|
+
module Tree::Utils::TreeMergeHandlerTree40,1769
|
55
|
+
def merge(other_tree)merge57,2498
|
56
|
+
def merge!(other_tree)merge!72,3132
|
57
|
+
def check_merge_prerequisites(other_tree)check_merge_prerequisites85,3439
|
58
|
+
def merge_trees(tree1, tree2)merge_trees102,4084
|
59
|
+
|
60
|
+
../lib/tree/utils/utils.rb,32
|
61
|
+
module Tree::UtilsTree39,1838
|
62
|
+
|
63
|
+
../lib/tree/version.rb,25
|
64
|
+
module TreeTree38,1717
|
65
|
+
|
66
|
+
../lib/tree.rb,2022
|
67
|
+
module TreeTree53,2335
|
68
|
+
class TreeNodeTreeNode90,3884
|
69
|
+
def rootroot131,5161
|
70
|
+
def is_root?is_root?142,5467
|
71
|
+
def has_content?has_content?150,5650
|
72
|
+
def is_leaf?is_leaf?161,5904
|
73
|
+
def parentageparentage173,6279
|
74
|
+
def has_children?has_children?191,6705
|
75
|
+
def initialize(name, content = nil)initialize214,7531
|
76
|
+
def detached_copydetached_copy232,8148
|
77
|
+
def detached_subtree_copydetached_subtree_copy242,8434
|
78
|
+
def marshal_dumpmarshal_dump256,8873
|
79
|
+
def create_dump_rep # :nodoc:create_dump_rep262,9041
|
80
|
+
def marshal_load(dumped_tree_array)marshal_load277,9579
|
81
|
+
def to_sto_s302,10363
|
82
|
+
def <<(child)<<325,11134
|
83
|
+
def add(child, at_index = -1)add360,12640
|
84
|
+
def insertion_rangeinsertion_range379,13509
|
85
|
+
def remove!(child)remove!401,14296
|
86
|
+
def parent=(parent) # :nodoc:parent=416,14699
|
87
|
+
def remove_from_parent!remove_from_parent!429,15084
|
88
|
+
def remove_all!remove_all!440,15456
|
89
|
+
def set_as_root! # :nodoc:set_as_root!451,15685
|
90
|
+
def freeze_tree!freeze_tree!461,16011
|
91
|
+
def [](name_or_index, num_as_name=false)[]501,17529
|
92
|
+
def each(&block) # :yields: nodeeach526,18496
|
93
|
+
def preordered_each(&block) # :yields: nodepreordered_each554,19456
|
94
|
+
def postordered_each(&block)postordered_each566,19868
|
95
|
+
def breadth_each(&block)breadth_each602,21294
|
96
|
+
def childrenchildren628,22232
|
97
|
+
def each_leaf &blockeach_leaf649,22853
|
98
|
+
def first_childfirst_child666,23275
|
99
|
+
def last_childlast_child674,23486
|
100
|
+
def first_siblingfirst_sibling690,23933
|
101
|
+
def is_first_sibling?is_first_sibling?700,24207
|
102
|
+
def last_siblinglast_sibling714,24623
|
103
|
+
def is_last_sibling?is_last_sibling?724,24893
|
104
|
+
def siblingssiblings740,25446
|
105
|
+
def is_only_child?is_only_child?759,25998
|
106
|
+
def next_siblingnext_sibling772,26401
|
107
|
+
def previous_siblingprevious_sibling788,26875
|
108
|
+
def <=>(other)<=>804,27386
|
109
|
+
def print_tree(level = 0)print_tree812,27615
|
110
|
+
|
111
|
+
../test/test_binarytree.rb,798
|
112
|
+
module TestTreeTestTree39,1717
|
113
|
+
class TestBinaryTreeNode < Test::Unit::TestCaseTestBinaryTreeNode41,1774
|
114
|
+
def setupsetup44,1864
|
115
|
+
def teardownteardown52,2167
|
116
|
+
def test_initializetest_initialize59,2326
|
117
|
+
def test_addtest_add67,2715
|
118
|
+
def test_inordered_eachtest_inordered_each90,3629
|
119
|
+
def test_left_childtest_left_child134,5097
|
120
|
+
def test_right_childtest_right_child142,5410
|
121
|
+
def test_left_child_equalstest_left_child_equals150,5723
|
122
|
+
def test_right_child_equalstest_right_child_equals169,6713
|
123
|
+
def test_is_left_child_ehtest_is_left_child_eh189,7830
|
124
|
+
def test_is_right_child_ehtest_is_right_child_eh204,8369
|
125
|
+
def test_swap_childrentest_swap_children218,8915
|
126
|
+
def test_old_camelCase_method_namestest_old_camelCase_method_names236,9798
|
127
|
+
|
128
|
+
../test/test_rubytree_require.rb,180
|
129
|
+
module TestTreeTestTree38,1678
|
130
|
+
class TestRequireRubytree < Test::Unit::TestCaseTestRequireRubytree41,1757
|
131
|
+
def test_create_a_simple_nodetest_create_a_simple_node44,1880
|
132
|
+
|
133
|
+
../test/test_subclassed_node.rb,301
|
134
|
+
module TestTreeTestTree39,1688
|
135
|
+
class TestSubclassedTreeNode < Test::Unit::TestCaseTestSubclassedTreeNode42,1739
|
136
|
+
class MyNode < Tree::TreeNodeMyNode45,1864
|
137
|
+
def my_dummy_methodmy_dummy_method47,1961
|
138
|
+
def test_subclassed_camelcase_methodstest_subclassed_camelcase_methods52,2022
|
139
|
+
|
140
|
+
../test/test_thread_and_fiber.rb,331
|
141
|
+
module TestTreeTestTree39,1695
|
142
|
+
class TestFiberAndThreadOnNode < Test::Unit::TestCaseTestFiberAndThreadOnNode41,1745
|
143
|
+
def create_long_depth_trees(depth=100)create_long_depth_trees44,1839
|
144
|
+
def test_fiber_for_recursiontest_fiber_for_recursion59,2256
|
145
|
+
def test_thread_for_recursiontest_thread_for_recursion73,2803
|
146
|
+
|
147
|
+
../test/test_tree.rb,3873
|
148
|
+
module TestTreeTestTree39,1719
|
149
|
+
class TestTreeNode < Test::Unit::TestCaseTestTreeNode41,1769
|
150
|
+
def setupsetup65,2600
|
151
|
+
def setup_test_treesetup_test_tree77,3020
|
152
|
+
def teardownteardown84,3170
|
153
|
+
def test_has_version_numbertest_has_version_number89,3262
|
154
|
+
def test_root_setuptest_root_setup94,3413
|
155
|
+
def test_roottest_root111,4463
|
156
|
+
def test_has_content_ehtest_has_content_eh124,5013
|
157
|
+
def test_length_is_sizetest_length_is_size135,5471
|
158
|
+
def test_spaceshiptest_spaceship141,5661
|
159
|
+
def test_is_comparabletest_is_comparable167,6444
|
160
|
+
def test_to_stest_to_s185,7226
|
161
|
+
def test_first_siblingtest_first_sibling218,8944
|
162
|
+
def test_is_first_sibling_ehtest_is_first_sibling_eh231,9672
|
163
|
+
def test_is_last_sibling_ehtest_is_last_sibling_eh242,10155
|
164
|
+
def test_last_siblingtest_last_sibling253,10623
|
165
|
+
def test_siblingstest_siblings265,11277
|
166
|
+
def test_is_only_child_ehtest_is_only_child_eh293,12200
|
167
|
+
def test_next_siblingtest_next_sibling304,12636
|
168
|
+
def test_previous_siblingtest_previous_sibling315,13136
|
169
|
+
def test_addtest_add326,13665
|
170
|
+
def test_add_at_specific_positiontest_add_at_specific_position350,14474
|
171
|
+
def test_remove_bangtest_remove_bang414,17527
|
172
|
+
def test_remove_all_bangtest_remove_all_bang446,18490
|
173
|
+
def test_remove_from_parent_bangtest_remove_from_parent_bang456,18796
|
174
|
+
def test_childrentest_children475,19511
|
175
|
+
def test_first_childtest_first_child511,21100
|
176
|
+
def test_last_childtest_last_child520,21428
|
177
|
+
def test_findtest_find529,21744
|
178
|
+
def test_parentagetest_parentage544,22339
|
179
|
+
def test_eachtest_each553,22671
|
180
|
+
def test_each_leaftest_each_leaf572,23355
|
181
|
+
def test_parenttest_parent599,24550
|
182
|
+
def test_indexed_accesstest_indexed_access610,24969
|
183
|
+
def test_print_treetest_print_tree621,25342
|
184
|
+
def test_marshal_dumptest_marshal_dump628,25502
|
185
|
+
def test_collecttest_collect673,27745
|
186
|
+
def test_freeze_tree_bangtest_freeze_tree_bang683,28011
|
187
|
+
def test_contenttest_content697,28533
|
188
|
+
def test_depthtest_depth705,28924
|
189
|
+
def do_deprecated_depthdo_deprecated_depth716,29297
|
190
|
+
def test_node_heighttest_node_height734,29865
|
191
|
+
def test_node_depthtest_node_depth759,31074
|
192
|
+
def test_leveltest_level772,31511
|
193
|
+
def test_breadthtest_breadth787,32054
|
194
|
+
def test_breadth_eachtest_breadth_each806,32701
|
195
|
+
def test_preordered_eachtest_preordered_each847,34007
|
196
|
+
def test_postordered_eachtest_postordered_each886,35261
|
197
|
+
def test_detached_copytest_detached_copy925,36516
|
198
|
+
def test_detached_subtree_copytest_detached_subtree_copy942,37244
|
199
|
+
def test_has_children_ehtest_has_children_eh976,39496
|
200
|
+
def test_is_leaf_ehtest_is_leaf_eh982,39658
|
201
|
+
def test_is_root_ehtest_is_root_eh989,39864
|
202
|
+
def test_content_equalstest_content_equals995,40027
|
203
|
+
def test_sizetest_size1003,40292
|
204
|
+
def test_lt2 # Test the << methodtest_lt21012,40556
|
205
|
+
def test_index # Test the [] methodtest_index1023,41048
|
206
|
+
def test_in_degreetest_in_degree1044,42144
|
207
|
+
def test_out_degreetest_out_degree1055,42611
|
208
|
+
def test_json_serializationtest_json_serialization1066,43098
|
209
|
+
def test_json_deserializationtest_json_deserialization1090,43898
|
210
|
+
def test_json_roundtriptest_json_roundtrip1118,45084
|
211
|
+
def test_old_camelCase_method_namestest_old_camelCase_method_names1134,45825
|
212
|
+
def test_integer_node_namestest_integer_node_names1165,46893
|
213
|
+
def test_add_node_to_self_as_childtest_add_node_to_self_as_child1196,48123
|
214
|
+
def test_single_node_becomes_leaftest_single_node_becomes_leaf1208,48548
|
215
|
+
def test_unique_node_namestest_unique_node_names1219,48895
|
216
|
+
def setup_other_test_treesetup_other_test_tree1227,49139
|
217
|
+
def test_mergetest_merge1255,50128
|
218
|
+
def test_merge_bangtest_merge_bang1284,51566
|
data/TODO.org
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# -*- mode: org; coding: utf-8-unix; fill-column: 120; -*-
|
2
2
|
#+OPTIONS: ^:{}
|
3
|
+
#+TODO: TODO(t) STARTED(s) | DONE(d) CANCELED(c)
|
4
|
+
#+LINK: Issue https://github.com/evolve75/RubyTree/issues/%s
|
5
|
+
#+LINK: Pull https://github.com/evolve75/RubyTree/pull/%s
|
3
6
|
|
4
7
|
* R0.7.0 :ARCHIVE:
|
5
8
|
*** DONE Start using signed tags from R0.7.0 :ARCHIVE:
|
@@ -17,8 +20,6 @@
|
|
17
20
|
CLOSED: [2010-01-30 Sat 23:56]
|
18
21
|
|
19
22
|
|
20
|
-
|
21
|
-
|
22
23
|
* R0.8.0 :ARCHIVE:
|
23
24
|
*** DONE Convert all method names to the canonical /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/ pattern :ARCHIVE:
|
24
25
|
See Roodi report at http://getcaliper.com/caliper/tool?tool=roodi&repo=git://github.com/evolve75/RubyTree.git
|
@@ -30,44 +31,10 @@
|
|
30
31
|
*** DONE Fix [[http://rubyforge.org/tracker/index.php?func%3Ddetail&aid%3D28613&group_id%3D1215&atid%3D4793][bug #28613]] which was affecting the `leftChild=' and `rightChild=' methods for binary trees. :ARCHIVE:
|
31
32
|
|
32
33
|
|
33
|
-
|
34
|
-
* R0.8.3
|
34
|
+
* R0.8.3 :ARCHIVE:
|
35
35
|
|
36
36
|
This is a bugfix release.
|
37
37
|
|
38
|
-
*** TODO [#A] Resolve the infinite loop bug if a node is added to itself as a child :Partial:
|
39
|
-
Issue https://github.com/evolve75/RubyTree/issues/5
|
40
|
-
|
41
|
-
This is a subtle problem to resolve. The specific case of a node
|
42
|
-
being added to itself is trivial to resolve, and the fix has been
|
43
|
-
put in for 0.8.3.
|
44
|
-
|
45
|
-
However, the general problem is that in the current code, a node
|
46
|
-
can be added as a child to any portion of the tree down the
|
47
|
-
hierarchy (e.g., as a grandchild), which will need a more thorough
|
48
|
-
detection code in the ~TreeNode#add~ method, if it is to be done at
|
49
|
-
runtime.
|
50
|
-
|
51
|
-
The issue is really to prevent the tree becoming a graph. Note
|
52
|
-
that the issue is with duplicate nodes, /not/ duplicated content.
|
53
|
-
|
54
|
-
A few options exist:
|
55
|
-
1. Perform a runtime check in the ~TreeNode#add~ method. This will
|
56
|
-
cause a performance hit as the tree becomes larger.
|
57
|
-
2. Allow the additions to go through, but create a new ~validate~
|
58
|
-
method that checks for such cycles.
|
59
|
-
3. Create separate configuration object which can be attached to
|
60
|
-
the root of the tree, which allows per-tree configuration of
|
61
|
-
the behavior - this does allow for the user to take control,
|
62
|
-
but also introduces complications during tree mergers and
|
63
|
-
spitting subtrees.
|
64
|
-
4. Create a registry (to be maintained at the root?) of all nodes,
|
65
|
-
and use this for validating the node additions (and preventing
|
66
|
-
duplicates). This needs to be a hash (to allow O(1) access),
|
67
|
-
and will sacrifice memory. There might be a need to
|
68
|
-
restructure the internals to make better use of memory.
|
69
|
-
|
70
|
-
|
71
38
|
*** DONE Make Rubytree compatible with Bundler :ARCHIVE:
|
72
39
|
CLOSED: [2012-08-21 Tue 21:04]
|
73
40
|
|
@@ -149,15 +116,120 @@
|
|
149
116
|
Left the code as-is, since we need some way to un-ambiguously find the root, regardless of the node given.
|
150
117
|
|
151
118
|
|
119
|
+
|
152
120
|
* R0.9.0
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
121
|
+
DEADLINE: <2013-02-24 Sun>
|
122
|
+
|
123
|
+
This release contains the following features and fixes:
|
124
|
+
|
125
|
+
1. Ability to merge in another tree at a chosen node
|
126
|
+
2. Support for the [[http://ruby-doc.org/core-1.8.7/Comparable.html][Comparable]] mixin module
|
127
|
+
3. Ability to export the tree to a hash, and create a new tree from
|
128
|
+
another existing hash
|
129
|
+
4. Fix (partial) for preventing cyclic graphs in the tree
|
130
|
+
5. Refactored =each= method to prevent stack errors while navigating
|
131
|
+
deep trees
|
132
|
+
6. Check to ensure that the added node's name is unique to the destination tree
|
133
|
+
7. Fix for the issue where tree traversal would fail if the binary-tree's left child was nil
|
134
|
+
8. Fixed the return type for the iterator methods (each, postordered_each, breadth_each, etc.). They now return an
|
135
|
+
Enumerator if *no* block is provided, or else return the receiver node itself, if a block *was* provided. This is
|
136
|
+
consistent with how Ruby's standard collections work
|
137
|
+
9. Structural changes in the code to refactor out the non-core functions into modules
|
138
|
+
10. Massive documentation updates
|
139
|
+
11. Addition of the examples directory (only a bare-bones placeholder for now, with the basic example code)
|
140
|
+
12. Ability to run the examples from the Rakefile
|
141
|
+
13. Various bundler and travis-ci related changes
|
142
|
+
|
143
|
+
|
144
|
+
*** DONE Fix the stack exhaustion issue due to deep recursion on very large unbalanced trees :ARCHIVE:
|
145
|
+
CLOSED: [2013-12-28 Sat 10:59]
|
146
|
+
See [[Issue:12][Issue #12.]] The following methods need fixes:
|
147
|
+
- [X] [[file:lib/tree.rb::def%20each(][each]]
|
148
|
+
- [X] [[file:lib/tree.rb::def%20postordered_each][postordered_each]]
|
149
|
+
|
150
|
+
*** DONE Extract non-essential methods from Tree::TreeNode into separate files. :ARCHIVE:
|
151
|
+
CLOSED: [2013-12-31 Tue 21:55]
|
152
|
+
- [X] Handling of CamelCase methods
|
153
|
+
- [X] Convertion to and from [[http://flori.github.com/json/][JSON]]
|
154
|
+
- [X] The merge feature
|
155
|
+
- [X] The metrics measurements
|
156
|
+
|
157
|
+
*** DONE Fix the documentation strings for the methods (the Yard attributes) :ARCHIVE:
|
158
|
+
CLOSED: [2013-12-31 Tue 21:55] DEADLINE: <2013-12-28 Sat>
|
159
|
+
|
160
|
+
*** DONE Implement an `inordered_each` method for the [[file:lib/tree/b][BinaryTree]] :ARCHIVE:
|
161
|
+
CLOSED: [2013-12-28 Sat 16:32] DEADLINE: <2013-12-28 Sat>
|
162
|
+
*** DONE Add some example code to the Gem :ARCHIVE:
|
163
|
+
CLOSED: [2013-12-28 Sat 12:12]
|
164
|
+
*** DONE Pull in the unique node name validation from [[Pull:9][ysf]] :ARCHIVE:
|
165
|
+
CLOSED: [2013-02-21 Thu 20:29]
|
166
|
+
Will need to make this configurable.
|
167
|
+
|
168
|
+
*** DONE Pull in the tree merge feature from [[Pull:9][Dazoakley]] :ARCHIVE:
|
169
|
+
CLOSED: [2013-02-21 Thu 20:26]
|
170
|
+
|
171
|
+
*** DONE Rename the [[file:COPYING.rdoc][COPYING.rdoc]] file to LICENSING.rdoc :ARCHIVE:
|
172
|
+
CLOSED: [2012-08-25 Sat 21:19]
|
173
|
+
|
174
|
+
*** CANCELED Fix the inconsistency of returning root as its first sibling, and returning a nil instead. Ditto for last sibling. :ARCHIVE:
|
175
|
+
CLOSED: [2012-08-25 Sat 20:49]
|
176
|
+
This is actually consistent.
|
177
|
+
*** CANCELED fix the inconsistency of returning nil for the root, and an empty array for nodes which have no siblings. :ARCHIVE:
|
178
|
+
CLOSED: [2012-08-25 Sat 20:51]
|
179
|
+
Already fixed in [[R0.8.3]].
|
180
|
+
|
181
|
+
*** CANCELED We should perhaps return nil as root's root. (Scrapped). :ARCHIVE:
|
182
|
+
CLOSED: [2012-08-25 Sat 20:35]
|
183
|
+
This proposed change does make sense at one level (since the root node does not have any parent), but returning root
|
184
|
+
as root's root (no pun intended) makes accessing the root from anywhere in the tree much easier.
|
185
|
+
|
186
|
+
|
187
|
+
* Next Release
|
188
|
+
** STARTED [#A] Resolve the infinite loop bug if a node is added to itself as a child :Partial:
|
189
|
+
[[Issue:5][Issue #5.]]
|
190
|
+
|
191
|
+
This is a subtle problem to resolve. The specific case of a node
|
192
|
+
being added to itself is trivial to resolve, and the fix has been
|
193
|
+
put in for 0.8.3.
|
194
|
+
|
195
|
+
However, the general problem is that in the current code, a node
|
196
|
+
can be added as a child to any portion of the tree down the
|
197
|
+
hierarchy (e.g., as a grandchild), which will need a more thorough
|
198
|
+
detection code in the ~TreeNode#add~ method, if it is to be done at
|
199
|
+
runtime.
|
200
|
+
|
201
|
+
The issue is really to prevent the tree becoming a graph. Note
|
202
|
+
that the issue is with duplicate nodes, /not/ duplicated content.
|
203
|
+
|
204
|
+
A few options exist:
|
205
|
+
1. Perform a runtime check in the ~TreeNode#add~ method. This will
|
206
|
+
cause a performance hit as the tree becomes larger.
|
207
|
+
2. Allow the additions to go through, but create a new ~validate~
|
208
|
+
method that checks for such cycles.
|
209
|
+
3. Create separate configuration object which can be attached to
|
210
|
+
the root of the tree, which allows per-tree configuration of
|
211
|
+
the behavior - this does allow for the user to take control,
|
212
|
+
but also introduces complications during tree mergers and
|
213
|
+
spitting subtrees.
|
214
|
+
4. Create a registry (to be maintained at the root?) of all nodes,
|
215
|
+
and use this for validating the node additions (and preventing
|
216
|
+
duplicates). This needs to be a hash (to allow O(1) access),
|
217
|
+
and will sacrifice memory. There might be a need to
|
218
|
+
restructure the internals to make better use of memory.
|
219
|
+
** TODO Expand the examples section, and add supporting documentation
|
220
|
+
** TODO Pull the =hash= converter code from [[https://github.com/markthomas/RubyTree/commits/master][Mark Thomas]] ([[Issue:13][Issue #13]]).
|
221
|
+
|
222
|
+
|
158
223
|
|
159
224
|
|
160
225
|
* Unplanned / Not assigned to any release
|
226
|
+
*** TODO Create a cycle-detection/validation mechanism to prevent cyclic graphs of nodes.
|
227
|
+
*** TODO Revert the forced install of rubygem 2.1.11 from [[file:.travis.yml][.travis.yml]]
|
228
|
+
*** TODO Create a generic validation method to check for various issues in the created tree.
|
229
|
+
*** TODO Add a FAQ document to the project.
|
230
|
+
*** TODO The semantic of length is probably unclear. Should return the node_depth instead (or remove the method)
|
231
|
+
The current equivalence of length to size should also be removed.
|
232
|
+
|
161
233
|
*** TODO Create the basic UML diagrams and upload to the Site
|
162
234
|
DEADLINE: <2010-01-04 Mon>
|
163
235
|
|