• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

More BitSet Questions - Please send help

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using the java.util.BitSet class.
I have questions if I am using the BitSet methods
correctly. I am using clear and set. See below...
Will 'clear' method, clear the bit to 'off' or clear it to '0'?
Will 'set' method, set the bit 'on' or set it to '1'?
----------------------
Definitions:
private BitSet Bits;
private int BitIndex;
Instianiate:
Bits = new HuffBitSet(25);
Use:
Bits = bits.clear(BitIndex);
Bits = bits.set(BitIndex);
 
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The class BitSet implements a vector of bits that grows as needed. Each component of the bit set has a boolean value.By default, all bits in the set initially have the value false.
clear(index) - Sets the bit specified by the index to false.
set(index) - Sets the bit specified by the index to true.
Check out the following code

Output is :
Bit is false
Bit is true
Bit is false
Hope this helps
 
This tiny ad is guaranteed to be gluten free.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic