Lines Matching refs:fromIndex

358      * Checks that fromIndex ... toIndex is a valid range of bit indices.
360 private static void checkRange(int fromIndex, int toIndex) {
361 if (fromIndex < 0)
362 throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
365 if (fromIndex > toIndex)
366 throw new IndexOutOfBoundsException("fromIndex: " + fromIndex +
392 * Sets each bit from the specified {@code fromIndex} (inclusive) to the
396 * @param fromIndex index of the first bit to flip
398 * @throws IndexOutOfBoundsException if {@code fromIndex} is negative,
399 * or {@code toIndex} is negative, or {@code fromIndex} is
403 public void flip(int fromIndex, int toIndex) {
404 checkRange(fromIndex, toIndex);
406 if (fromIndex == toIndex)
409 int startWordIndex = wordIndex(fromIndex);
413 long firstWordMask = WORD_MASK << fromIndex;
470 * Sets the bits from the specified {@code fromIndex} (inclusive) to the
473 * @param fromIndex index of the first bit to be set
475 * @throws IndexOutOfBoundsException if {@code fromIndex} is negative,
476 * or {@code toIndex} is negative, or {@code fromIndex} is
480 public void set(int fromIndex, int toIndex) {
481 checkRange(fromIndex, toIndex);
483 if (fromIndex == toIndex)
487 int startWordIndex = wordIndex(fromIndex);
491 long firstWordMask = WORD_MASK << fromIndex;
513 * Sets the bits from the specified {@code fromIndex} (inclusive) to the
516 * @param fromIndex index of the first bit to be set
519 * @throws IndexOutOfBoundsException if {@code fromIndex} is negative,
520 * or {@code toIndex} is negative, or {@code fromIndex} is
524 public void set(int fromIndex, int toIndex, boolean value) {
526 set(fromIndex, toIndex);
528 clear(fromIndex, toIndex);
553 * Sets the bits from the specified {@code fromIndex} (inclusive) to the
556 * @param fromIndex index of the first bit to be cleared
558 * @throws IndexOutOfBoundsException if {@code fromIndex} is negative,
559 * or {@code toIndex} is negative, or {@code fromIndex} is
563 public void clear(int fromIndex, int toIndex) {
564 checkRange(fromIndex, toIndex);
566 if (fromIndex == toIndex)
569 int startWordIndex = wordIndex(fromIndex);
579 long firstWordMask = WORD_MASK << fromIndex;
634 * from {@code fromIndex} (inclusive) to {@code toIndex} (exclusive).
636 * @param fromIndex index of the first bit to include
639 * @throws IndexOutOfBoundsException if {@code fromIndex} is negative,
640 * or {@code toIndex} is negative, or {@code fromIndex} is
644 public BitSet get(int fromIndex, int toIndex) {
645 checkRange(fromIndex, toIndex);
652 if (len <= fromIndex || fromIndex == toIndex)
659 BitSet result = new BitSet(toIndex - fromIndex);
660 int targetWords = wordIndex(toIndex - fromIndex - 1) + 1;
661 int sourceIndex = wordIndex(fromIndex);
662 boolean wordAligned = ((fromIndex & BIT_INDEX_MASK) == 0);
667 (words[sourceIndex] >>> fromIndex) |
668 (words[sourceIndex+1] << -fromIndex);
673 ((toIndex-1) & BIT_INDEX_MASK) < (fromIndex & BIT_INDEX_MASK)
675 ((words[sourceIndex] >>> fromIndex) |
676 (words[sourceIndex+1] & lastWordMask) << -fromIndex)
678 ((words[sourceIndex] & lastWordMask) >>> fromIndex);
704 * @param fromIndex the index to start checking from (inclusive)
710 public int nextSetBit(int fromIndex) {
711 if (fromIndex < 0)
712 throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
716 int u = wordIndex(fromIndex);
720 long word = words[u] & (WORD_MASK << fromIndex);
735 * @param fromIndex the index to start checking from (inclusive)
740 public int nextClearBit(int fromIndex) {
743 if (fromIndex < 0)
744 throw new IndexOutOfBoundsException("fromIndex < 0: " + fromIndex);
748 int u = wordIndex(fromIndex);
750 return fromIndex;
752 long word = ~words[u] & (WORD_MASK << fromIndex);
777 * @param fromIndex the index to start checking from (inclusive)
784 public int previousSetBit(int fromIndex) {
785 if (fromIndex < 0) {
786 if (fromIndex == -1)
789 "fromIndex < -1: " + fromIndex);
794 int u = wordIndex(fromIndex);
798 long word = words[u] & (WORD_MASK >>> -(fromIndex+1));
815 * @param fromIndex the index to start checking from (inclusive)
822 public int previousClearBit(int fromIndex) {
823 if (fromIndex < 0) {
824 if (fromIndex == -1)
827 "fromIndex < -1: " + fromIndex);
832 int u = wordIndex(fromIndex);
834 return fromIndex;
836 long word = ~words[u] & (WORD_MASK >>> -(fromIndex+1));