Class: QuartzTorrent::EmptyBitfield
- Defined in:
- lib/quartz_torrent/bitfield.rb
Overview
A bitfield that is always empty.
Instance Attribute Summary collapse
-
#length ⇒ Object
readonly
Length of the Bitfield in bits.
Instance Method Summary collapse
-
#allClear? ⇒ Boolean
Are all bits in the Bitfield clear?.
-
#allSet? ⇒ Boolean
Are all bits in the Bitfield set?.
-
#byteLength ⇒ Object
Length of the Bitfield in bytes.
-
#clear(bit) ⇒ Object
Clear the bit at index ‘bit’ to 0.
-
#clearAll ⇒ Object
Clear all bits in the field to 0.
-
#compliment ⇒ Object
Calculate the compliment of this bitfield, and return the result as a new bitfield.
-
#compliment! ⇒ Object
Update this bitfield to be the compliment of itself.
-
#copyFrom(bitfield) ⇒ Object
Set the contents of this bitfield to be the same as the passed bitfield.
-
#countSet ⇒ Object
Count the number of bits that are set.
-
#initialize ⇒ EmptyBitfield
constructor
A new instance of EmptyBitfield.
-
#intersection(bitfield) ⇒ Object
Calculate the intersection of this bitfield and the passed bitfield, and return the result as a new bitfield.
-
#intersection!(bitfield) ⇒ Object
Update this bitfield to be the intersection of this bitfield and the passed bitfield.
-
#serialize ⇒ Object
Serialize this bitfield as a string.
-
#set(bit) ⇒ Object
Set the bit at index ‘bit’ to 1.
-
#set?(bit) ⇒ Boolean
Returns true if the bit is set, false otherwise.
-
#setAll ⇒ Object
Set all bits in the field to 1.
-
#to_s(groupsOf = 8) ⇒ Object
Return a display string representing the bitfield.
-
#union(bitfield) ⇒ Object
Calculate the union of this bitfield and the passed bitfield, and return the result as a new bitfield.
-
#unserialize(s) ⇒ Object
Unserialize this bitfield from a string.
Constructor Details
#initialize ⇒ EmptyBitfield
Returns a new instance of EmptyBitfield.
230 231 232 |
# File 'lib/quartz_torrent/bitfield.rb', line 230 def initialize @length = 0 end |
Instance Attribute Details
#length ⇒ Object (readonly)
Length of the Bitfield in bits.
235 236 237 |
# File 'lib/quartz_torrent/bitfield.rb', line 235 def length @length end |
Instance Method Details
#allClear? ⇒ Boolean
Are all bits in the Bitfield clear?
261 262 263 |
# File 'lib/quartz_torrent/bitfield.rb', line 261 def allClear? true end |
#allSet? ⇒ Boolean
Are all bits in the Bitfield set?
256 257 258 |
# File 'lib/quartz_torrent/bitfield.rb', line 256 def allSet? false end |
#byteLength ⇒ Object
Length of the Bitfield in bytes.
238 239 240 |
# File 'lib/quartz_torrent/bitfield.rb', line 238 def byteLength 0 end |
#clear(bit) ⇒ Object
Clear the bit at index ‘bit’ to 0.
247 248 |
# File 'lib/quartz_torrent/bitfield.rb', line 247 def clear(bit) end |
#clearAll ⇒ Object
Clear all bits in the field to 0.
270 271 |
# File 'lib/quartz_torrent/bitfield.rb', line 270 def clearAll end |
#compliment ⇒ Object
Calculate the compliment of this bitfield, and return the result as a new bitfield.
297 298 299 |
# File 'lib/quartz_torrent/bitfield.rb', line 297 def compliment self end |
#compliment! ⇒ Object
Update this bitfield to be the compliment of itself.
302 303 304 |
# File 'lib/quartz_torrent/bitfield.rb', line 302 def compliment! self end |
#copyFrom(bitfield) ⇒ Object
Set the contents of this bitfield to be the same as the passed bitfield. An exception is thrown if the passed bitfield is smaller than this.
292 293 |
# File 'lib/quartz_torrent/bitfield.rb', line 292 def copyFrom(bitfield) end |
#countSet ⇒ Object
Count the number of bits that are set. Slow: could use lookup table.
321 322 323 |
# File 'lib/quartz_torrent/bitfield.rb', line 321 def countSet 0 end |
#intersection(bitfield) ⇒ Object
Calculate the intersection of this bitfield and the passed bitfield, and return the result as a new bitfield.
281 282 283 |
# File 'lib/quartz_torrent/bitfield.rb', line 281 def intersection(bitfield) self end |
#intersection!(bitfield) ⇒ Object
Update this bitfield to be the intersection of this bitfield and the passed bitfield.
286 287 288 |
# File 'lib/quartz_torrent/bitfield.rb', line 286 def intersection!(bitfield) self end |
#serialize ⇒ Object
Serialize this bitfield as a string.
307 308 309 |
# File 'lib/quartz_torrent/bitfield.rb', line 307 def serialize "" end |
#set(bit) ⇒ Object
Set the bit at index ‘bit’ to 1.
243 244 |
# File 'lib/quartz_torrent/bitfield.rb', line 243 def set(bit) end |
#set?(bit) ⇒ Boolean
Returns true if the bit is set, false otherwise.
251 252 253 |
# File 'lib/quartz_torrent/bitfield.rb', line 251 def set?(bit) false end |
#setAll ⇒ Object
Set all bits in the field to 1.
266 267 |
# File 'lib/quartz_torrent/bitfield.rb', line 266 def setAll end |
#to_s(groupsOf = 8) ⇒ Object
Return a display string representing the bitfield.
316 317 318 |
# File 'lib/quartz_torrent/bitfield.rb', line 316 def to_s(groupsOf = 8) "empty" end |
#union(bitfield) ⇒ Object
Calculate the union of this bitfield and the passed bitfield, and return the result as a new bitfield.
275 276 277 |
# File 'lib/quartz_torrent/bitfield.rb', line 275 def union(bitfield) self end |
#unserialize(s) ⇒ Object
Unserialize this bitfield from a string.
312 313 |
# File 'lib/quartz_torrent/bitfield.rb', line 312 def unserialize(s) end |