@@ -43,6 +43,9 @@ public final class BitString implements Cloneable, java.io.Serializable {
43
43
44
44
/**
45
45
* Convert bitIndex to a subscript into the bits[] array.
46
+ *
47
+ * @param bitIndex bit index
48
+ * @return subscript
46
49
*/
47
50
private static int subscript (int bitIndex ) {
48
51
return bitIndex >> BITS_PER_UNIT ;
@@ -63,6 +66,8 @@ public BitString(int nbits) {
63
66
64
67
/**
65
68
* Returns the first index in the bit string which is set, or -1 if there is no such index.
69
+ *
70
+ * @return the first index
66
71
*/
67
72
public int firstSet () {
68
73
return firstSet (-1 );
@@ -73,6 +78,7 @@ public int firstSet() {
73
78
* index.
74
79
*
75
80
* @param where the starting point for the search. May be negative.
81
+ * @return the first index
76
82
*/
77
83
public int firstSet (int where ) {
78
84
// convert exclusive starting point to inclusive starting point
@@ -175,6 +181,7 @@ public static final int bsr(int v) {
175
181
* index.
176
182
*
177
183
* @param where the starting point for the search.
184
+ * @return last index
178
185
*/
179
186
public int lastSet (int where ) {
180
187
// convert exclusive starting point to inclusive starting point
@@ -199,6 +206,8 @@ public int lastSet(int where) {
199
206
200
207
/**
201
208
* Returns the last index in the bit string which is set, or -1 if there is no such index.
209
+ *
210
+ * @return last index
202
211
*/
203
212
public int lastSet () {
204
213
return lastSet (size ());
@@ -291,6 +300,7 @@ public void clear(int bit) {
291
300
* Gets a bit.
292
301
*
293
302
* @param bit the bit to be gotten (zero-based)
303
+ * @return the bit
294
304
*/
295
305
public boolean get (int bit ) {
296
306
int n = subscript (bit );
@@ -302,6 +312,7 @@ public boolean get(int bit) {
302
312
* modified in response to the operation.
303
313
*
304
314
* @param set the bit set to be ANDed with
315
+ * @return modified
305
316
*/
306
317
public boolean and (BitString set ) {
307
318
if (this == set ) { // should help alias analysis
@@ -322,6 +333,7 @@ public boolean and(BitString set) {
322
333
* modified in response to the operation.
323
334
*
324
335
* @param set the bit set to be ORed with
336
+ * @return modified
325
337
*/
326
338
public boolean or (BitString set ) {
327
339
if (this == set ) { // should help alias analysis
@@ -342,6 +354,7 @@ public boolean or(BitString set) {
342
354
* modified in response to the operation.
343
355
*
344
356
* @param set the bit set to be ORed with
357
+ * @return modified
345
358
*/
346
359
public boolean or_upTo (BitString set , int bit ) {
347
360
if (this == set ) { // should help alias analysis
@@ -365,6 +378,7 @@ public boolean or_upTo(BitString set, int bit) {
365
378
* modified in response to the operation.
366
379
*
367
380
* @param set the bit set to be XORed with
381
+ * @return modified
368
382
*/
369
383
public boolean xor (BitString set ) {
370
384
int setLength = set .bits .length ;
@@ -382,6 +396,7 @@ public boolean xor(BitString set) {
382
396
* was modified in response to the operation.
383
397
*
384
398
* @param set the bit set to subtract
399
+ * @return modified
385
400
*/
386
401
public boolean minus (BitString set ) {
387
402
int n = bits .length ;
@@ -398,6 +413,7 @@ public boolean minus(BitString set) {
398
413
* Check if the intersection of the two sets is empty.
399
414
*
400
415
* @param other the set to check intersection with
416
+ * @return is empty or not
401
417
*/
402
418
public boolean intersectionEmpty (BitString other ) {
403
419
int n = bits .length ;
@@ -413,6 +429,7 @@ public boolean intersectionEmpty(BitString other) {
413
429
* Check if this set contains all bits of the given set.
414
430
*
415
431
* @param other the set to check containment with
432
+ * @return contains or not
416
433
*/
417
434
public boolean contains (BitString other ) {
418
435
int n = bits .length ;
@@ -523,6 +540,8 @@ public int hashCode() {
523
540
/**
524
541
* Returns the "logical size" of this <code>BitString</code>: the index of the highest set bit in the
525
542
* <code>BitString</code> plus one. Returns zero if the <code>BitString</code> contains no set bits.
543
+ *
544
+ * @return logical size
526
545
*/
527
546
public int length () {
528
547
return lastSet () + 1 ;
@@ -531,6 +550,8 @@ public int length() {
531
550
/**
532
551
* Returns the number of bits of space actually in use by this <code>BitString</code> to represent bit values. The
533
552
* maximum element in the set is the size - 1st element. The minimum element in the set is the zero'th element.
553
+ *
554
+ * @return number of bits
534
555
*/
535
556
public int size () {
536
557
return bits .length << BITS_PER_UNIT ;
@@ -656,6 +677,8 @@ public String toString() {
656
677
657
678
/**
658
679
* Returns an iterator that iterates through the bits in forward order.
680
+ *
681
+ * @return an iterator
659
682
*/
660
683
public ForwardBitStringIterator iterator () {
661
684
return new ForwardBitStringIterator ();
@@ -667,13 +690,17 @@ public ForwardBitStringZeroIterator zeroIterator() {
667
690
668
691
/**
669
692
* Returns an iterator that iterates through the bits in backward order.
693
+ *
694
+ * @return an iterator
670
695
*/
671
696
public BackwardBitStringIterator backwardsIterator () {
672
697
return new BackwardBitStringIterator ();
673
698
}
674
699
675
700
/**
676
701
* Returns an iterator that iterates through the bits in backward order, starting at the given index.
702
+ *
703
+ * @return an iterator
677
704
*/
678
705
public BackwardBitStringIterator backwardsIterator (int i ) {
679
706
return new BackwardBitStringIterator (i );
@@ -685,6 +712,8 @@ public BackwardBitStringIterator backwardsIterator(int i) {
685
712
public abstract static class BitStringIterator implements Iterator <Integer > {
686
713
/**
687
714
* Returns the index of the next bit set.
715
+ *
716
+ * @return the index
688
717
*/
689
718
public abstract int nextIndex ();
690
719
0 commit comments