Class: Hamster::MutableSet Private

Inherits:
Object
  • Object
show all
Includes:
ReadCopyUpdate
Defined in:
lib/hamster/experimental/mutable_set.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReadCopyUpdate

#eql?, #initialize

Dynamic Method Handling

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

Class Method Details

.[](*items) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



9
10
11
# File 'lib/hamster/experimental/mutable_set.rb', line 9

def self.[](*items)
  MutableSet.new(Set[*items])
end

Instance Method Details

#add(item) ⇒ Object Also known as: <<

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

#add?(item) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


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

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

#delete(item) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



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

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

#delete?(item) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


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

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