Class: Vertx::SharedData::SharedSet
- Inherits:
-
Object
- Object
- Vertx::SharedData::SharedSet
- Defined in:
- lib/vertx/shared_data.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #_to_java_set ⇒ Object
-
#add(obj) ⇒ SharedSet
Add an object to the set.
-
#add?(obj) ⇒ SharedSet
Add an object to the set.
-
#clear ⇒ Object
Clear the set.
-
#delete(obj) ⇒ Object
Delete an object from the set.
-
#delete?(obj) ⇒ SharedSet
Delete an object from the set.
-
#each(&block) ⇒ Object
Call the block for every element of the set.
-
#empty? ⇒ Boolean
True if the set is empty.
-
#include?(obj) ⇒ Boolean
Does the set contain an element?.
-
#initialize(j_set) ⇒ SharedSet
constructor
A new instance of SharedSet.
-
#size ⇒ FixNum
The number of elements in the set.
Constructor Details
#initialize(j_set) ⇒ SharedSet
Returns a new instance of SharedSet.
121 122 123 |
# File 'lib/vertx/shared_data.rb', line 121 def initialize(j_set) @j_set = j_set end |
Instance Method Details
#==(other) ⇒ Object
125 126 127 128 129 130 131 |
# File 'lib/vertx/shared_data.rb', line 125 def ==(other) if other.is_a?(SharedSet) @j_set.equal?(other._to_java_set) else false end end |
#_to_java_set ⇒ Object
208 209 210 |
# File 'lib/vertx/shared_data.rb', line 208 def _to_java_set @j_set end |
#add(obj) ⇒ SharedSet
Add an object to the set
136 137 138 139 140 |
# File 'lib/vertx/shared_data.rb', line 136 def add(obj) obj = SharedData.check_obj(obj) @j_set.add(obj) self end |
#add?(obj) ⇒ SharedSet
Add an object to the set
145 146 147 148 149 150 151 152 153 |
# File 'lib/vertx/shared_data.rb', line 145 def add?(obj) obj = SharedData.check_obj(obj) if !@j_set.contains(obj) @j_set.add(obj) self else nil end end |
#clear ⇒ Object
Clear the set
156 157 158 |
# File 'lib/vertx/shared_data.rb', line 156 def clear @j_set.clear end |
#delete(obj) ⇒ Object
Delete an object from the set
162 163 164 |
# File 'lib/vertx/shared_data.rb', line 162 def delete(obj) @j_set.remove(obj) end |
#delete?(obj) ⇒ SharedSet
Delete an object from the set
169 170 171 172 173 174 175 176 |
# File 'lib/vertx/shared_data.rb', line 169 def delete?(obj) if @j_set.contains(obj) @j_set.remove(obj) self else nil end end |
#each(&block) ⇒ Object
Call the block for every element of the set
180 181 182 183 184 185 186 187 |
# File 'lib/vertx/shared_data.rb', line 180 def each(&block) iter = @j_set.iterator while iter.hasNext do obj = iter.next obj = Buffer.new(obj) if obj.is_a? org.vertx.java.core.buffer.Buffer block.call(obj) end end |
#empty? ⇒ Boolean
Returns true if the set is empty.
190 191 192 |
# File 'lib/vertx/shared_data.rb', line 190 def empty? @j_set.isEmpty end |
#include?(obj) ⇒ Boolean
Does the set contain an element?
197 198 199 200 |
# File 'lib/vertx/shared_data.rb', line 197 def include?(obj) obj = obj._to_java_buffer if obj.is_a? Buffer @j_set.contains(obj) end |
#size ⇒ FixNum
Returns The number of elements in the set.
203 204 205 |
# File 'lib/vertx/shared_data.rb', line 203 def size @j_set.size end |