Class: Hamster::MutableSet

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hamster/experimental/mutable_set.rb

Instance Method Summary (collapse)

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Hamster::ReadCopyUpdate

Instance Method Details

- (Object) add(item)



14
15
16
# File 'lib/hamster/experimental/mutable_set.rb', line 14

def add(item)
  transform { |set| set.add(item) }
end

- (Boolean) add?(item)



19
20
21
22
23
24
25
26
# File 'lib/hamster/experimental/mutable_set.rb', line 19

def add?(item)
  added = false
  transform do |set|
    added = !set.include?(item)
    set.add(item)
  end
  added
end

- (Object) delete(item)



28
29
30
# File 'lib/hamster/experimental/mutable_set.rb', line 28

def delete(item)
  transform { |set| set.delete(item) }
end

- (Boolean) delete?(item)



32
33
34
35
36
37
38
39
# File 'lib/hamster/experimental/mutable_set.rb', line 32

def delete?(item)
  deleted = false
  transform do |set|
    deleted = set.include?(item)
    set.delete(item)
  end
  deleted
end