Sha256: 3d720a3c0e1fd8cb129d37942311e39b2bb8e160dbec14a64b425657e13c32da

Contents?: true

Size: 393 Bytes

Versions: 9

Compression:

Stored size: 393 Bytes

Contents

require 'set'

module Stages
  class Unique < Stage
    def initialize(options = { })
      @prefetch = options[:prefetch]
      super()
    end

    def process
      set = Set.new
      while !source_empty?
        i = input
        added = set.add? i
        handle_value i if added && !@prefetch
      end
      set.each{ |x| handle_value x} if @prefetch
      set = nil
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
stages-1.2.1 lib/stages/unique.rb
stages-1.2.0 lib/stages/unique.rb
stages-1.1.5 lib/stages/unique.rb
stages-1.1.2 lib/stages/unique.rb
stages-1.1.1 lib/stages/unique.rb
stages-1.0.1 lib/stages/unique.rb
stages-1.0.0 lib/stages/unique.rb
stages-0.4.1 lib/stages/unique.rb
stages-0.4.0 lib/stages/unique.rb