Sha256: 7a80f4a6bccf1a182920b1b86a4b518515d10af6f9d1b0802f89c970e204537c

Contents?: true

Size: 498 Bytes

Versions: 11

Compression:

Stored size: 498 Bytes

Contents

# typed: true

module Datadog
  module Core
    module Utils
      # Generates values from a consistent sequence
      class Sequence
        def initialize(seed = 0, &block)
          @seed = seed
          @current = seed
          @next_item = block
        end

        def next
          next_item = @next_item ? @next_item.call(@current) : @current
          @current += 1
          next_item
        end

        def reset!
          @current = @seed
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ddtrace-1.9.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.8.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.7.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.6.1 lib/datadog/core/utils/sequence.rb
ddtrace-1.6.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.5.2 lib/datadog/core/utils/sequence.rb
ddtrace-1.5.1 lib/datadog/core/utils/sequence.rb
ddtrace-1.5.0 lib/datadog/core/utils/sequence.rb
ddtrace-1.4.2 lib/datadog/core/utils/sequence.rb
ddtrace-1.4.1 lib/datadog/core/utils/sequence.rb
ddtrace-1.4.0 lib/datadog/core/utils/sequence.rb