Sha256: 7d4b83d3ea76dd262596afc3676c771ee624c7b298c3577c4575efd6dfe49de5

Contents?: true

Size: 538 Bytes

Versions: 3

Compression:

Stored size: 538 Bytes

Contents

module Rambling
  module Trie
    # Provides enumerable behavior to the Trie data structure.
    module Enumerable
      include ::Enumerable

      alias_method :size, :count

      # Iterates over the words contained in the trie.
      # @yield [String] the words contained in this trie node.
      def each
        return enum_for :each unless block_given?

        yield as_word if terminal?

        children.each do |child|
          child.each do |word|
            yield word
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rambling-trie-0.9.2 lib/rambling/trie/enumerable.rb
rambling-trie-0.9.1 lib/rambling/trie/enumerable.rb
rambling-trie-0.9.0 lib/rambling/trie/enumerable.rb