Sha256: cefc185805beff1714330640ede2810af43eec65a40606d6f7f10c860887c1a5

Contents?: true

Size: 917 Bytes

Versions: 123

Compression:

Stored size: 917 Bytes

Contents

module RSpec
  module Core
    # @private
    #
    # We use this to replace `::Set` so we can have the advantage of
    # constant time key lookups for unique arrays but without the
    # potential to pollute a developers environment with an extra
    # piece of the stdlib. This helps to prevent false positive
    # builds.
    #
    class Set
      include Enumerable

      def initialize(array=[])
        @values = {}
        merge(array)
      end

      def empty?
        @values.empty?
      end

      def <<(key)
        @values[key] = true
        self
      end

      def delete(key)
        @values.delete(key)
      end

      def each(&block)
        @values.keys.each(&block)
        self
      end

      def include?(key)
        @values.key?(key)
      end

      def merge(values)
        values.each do |key|
          @values[key] = true
        end
        self
      end
    end
  end
end

Version data entries

123 entries across 114 versions & 29 rubygems

Version Path
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/3.0.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.3.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/rspec-core-3.5.4/lib/rspec/core/set.rb