Sha256: 35b9f2cc7e2e7251b24cea2f30e6e80ff7dab40ded9448d6ba134bdbd8437904

Contents?: true

Size: 338 Bytes

Versions: 1

Compression:

Stored size: 338 Bytes

Contents

require 'set'
class Set
  # Picks an arbitrary element from the set and returns it. Use +pop+ to
  # pick and delete simultaneously.
  def pick
    @hash.first.first
  end

  # Picks an arbitrary element from the set and deletes it. Use +pick+ to
  # pick without deletion.
  def pop
    key = pick
    @hash.delete(key)
    key
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom_of_choice-1.0.0 lib/axiom_of_choice.rb