Sha256: 2313d074ec563a28ce0503bb5ca5e7ff942533012d8b3c0ee027699564e95b6c

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

module Pacer::Pipes
  class StreamUniqPipe < RubyPipe
    def initialize(buffer = 1000)
      super()
      @list = java.util.LinkedList.new
      @buffer = buffer
    end

    protected

    def processNextStart
      while true
        obj = @starts.next
        duplicate = @list.removeLastOccurrence(obj)
        @list.addLast obj
        if not duplicate
          if @buffer == 0
            @list.removeFirst
          else
            @buffer -= 1
          end
          return obj
        end
      end
    rescue NativeException => e
      if e.cause.getClass == NoSuchElementException.getClass
        raise e.cause
      else
        raise e
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pacer-0.9.1.1-java lib/pacer/pipe/stream_uniq_pipe.rb