Sha256: d1cec63de7bf3d293638f3ffe739a41936bb4505d7a9b4b49b8b46d940b73eae
Contents?: true
Size: 689 Bytes
Versions: 3
Compression:
Stored size: 689 Bytes
Contents
require "hamster/set" require "hamster/read_copy_update" module Hamster # @api private class MutableSet include ReadCopyUpdate def self.[](*items) MutableSet.new(Set[*items]) end def add(item) transform { |set| set.add(item) } end alias :<< :add def add?(item) added = false transform do |set| added = !set.include?(item) set.add(item) end added end def delete(item) transform { |set| set.delete(item) } end def delete?(item) deleted = false transform do |set| deleted = set.include?(item) set.delete(item) end deleted end end end
Version data entries
3 entries across 3 versions & 2 rubygems