Skip to content

Commit

Permalink
kill multimap#each_list
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed May 26, 2009
1 parent b7b39f3 commit 1266553
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 36 deletions.
10 changes: 1 addition & 9 deletions lib/multimap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@ def each_pair
alias_method :hash_each_value, :each_value
protected :hash_each_value

def each_list
hash_each_value do |value|
yield value
end
yield default
self
end

def each_value
each_pair do |key, value|
yield value
Expand Down Expand Up @@ -255,7 +247,7 @@ def to_hash

def lists
lists = []
each_list { |container| lists << container }
each_pair_list { |key, container| lists << container }
lists
end

Expand Down
12 changes: 0 additions & 12 deletions lib/nested_multimap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ def each_pair_list
end
end

def each_list
super do |container|
if container.respond_to?(:each_list)
container.each_list do |value|
yield value
end
else
yield container
end
end
end

def inspect
super.gsub(/\}$/, ", nil => #{default.inspect}}")
end
Expand Down
8 changes: 1 addition & 7 deletions spec/hash_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@
h.should == { "a" => [100], "b" => [200, 300] }
end

it "should iterate over each container" do
a = []
@map.each_list { |container| a << container }
a.should == [@container.new([100]), @container.new([200, 300]), @container.new]
end

it "should iterate over each value" do
a = []
@map.each_value { |value| a << value }
Expand Down Expand Up @@ -211,7 +205,7 @@
end

it "should return all containers" do
@map.lists.should == [@container.new([100]), @container.new([200, 300]), @container.new]
@map.lists.should == [@container.new([100]), @container.new([200, 300])]
end

it "should return all values" do
Expand Down
10 changes: 2 additions & 8 deletions spec/nested_multimap_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
end

it "should list all containers" do
@map.lists.should == [[100], [200, 300], []]
@map.lists.should == [[100], [200, 300]]
end

it "should list all values" do
Expand Down Expand Up @@ -121,20 +121,14 @@
}
end

it "should iterate over each container" do
a = []
@map.each_list { |container| a << container }
a.should == [[100], [200, 300], [200], [400, 500], [500], []]
end

it "should iterate over each value" do
a = []
@map.each_value { |value| a << value }
a.should == [100, 200, 300, 400, 500]
end

it "should list all containers" do
@map.lists.should == [[100], [200, 300], [200], [400, 500], [500], []]
@map.lists.should == [[100], [200, 300], [400, 500]]
end

it "should return array of keys" do
Expand Down

0 comments on commit 1266553

Please sign in to comment.