Module: Rambling::Trie::Enumerable
Overview
Provides enumerable behavior to the trie data structure.
Instance Method Summary collapse
-
#each {|String| ... } ⇒ self
Iterates over the words contained in the trie.
Instance Method Details
#each {|String| ... } ⇒ self
Iterates over the words contained in the trie.
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rambling/trie/enumerable.rb', line 16 def each return enum_for :each unless block_given? yield as_word if terminal? children_tree.each_value do |child| child.each do |word| yield word end end self end |