Support retrieving a subset of a BitSet using a Range

@param self  a BitSet
@param range a Range defining the desired subset
@return a new BitSet that represents the requested subset
@see java.util.BitSet
@see groovy.lang.IntRange
@since 1.5.0
427507
public static BitSet getAt(BitSet self, IntRange range) {
        RangeInfo info = subListBorders(self.length(), range);
        BitSet result = new BitSet();

        int numberOfBits = info.to - info.from;
        int adjuster = 1;
        int offset = info.from;

        if (info.reverse) {
            adjuster = -1;
            offset = info.to - 1;
        }

        for (int i = 0; i < numberOfBits; i++) {
            result.set(i, self.get(offset + (adjuster * i)));
        }

        return result;
    }
106934
public Iterator<RangeTombstone> rangeIterator()
    {
        return ranges == null ? Iterators.<RangeTombstone>emptyIterator() : ranges.iterator();
    }
759459
@Override
    public void seek(Range range, Collection<ByteSequence> columnFamilies, boolean inclusive) throws IOException {
        topKey = null;
        topValue = null;

        Key sk = range.getStartKey();

        if (sk != null
            && sk.getColumnFamilyData().length() == 0
            && sk.getColumnQualifierData().length() == 0
            && sk.getColumnVisibilityData().length() == 0
            && sk.getTimestamp() == Long.MAX_VALUE
            && !range.isStartKeyInclusive()) {
            // assuming that we are seeking using a key previously returned by this iterator therefore go the next row
            Key followingRowKey = sk.followingKey(PartialKey.ROW);
            if (range.getEndKey() != null && followingRowKey.compareTo(range.getEndKey()) > 0) {
                return;
            }

            range = new Range(sk.followingKey(PartialKey.ROW), true, range.getEndKey(), range.isEndKeyInclusive());
        }

        sourceIterator.seek(range, columnFamilies, inclusive);
        loadNext();
    }
1324058
public boolean intersects(Iterable<Range<T>> ranges)
    {
        for (Range<T> range2 : ranges)
        {
            if (range2.intersects(this))
                return true;
        }
        return false;
    }
1116350
@Override
  public boolean intersects(IVersionRange yourRange)
  {
    // The set has explicit versions, so just check these against the supplied range
    for (IVersion version : set) {
      if (yourRange.contains(version)) {
        return true;
      }
    }
    return false;
  }
901295
public function searchRange(Range $range)
    {
        $iterator = $this->getIterator();
        
        // find start
        $start = null;
        $binarySearch = new BinarySearch($this);
        $startHint = $binarySearch->search($range->getMin());
        if ($startHint == null) {
            return new RangeIterator($iterator, Range::getEmptyRange());
            
        }
        $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY);

        if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) {
            // shift $startHint higher
            
            foreach ($iterator as $result) {
                if ($range->contains($result->getKey())) {
                    $start = $result;
                    break;
                    
                }
            }
            
        } else {
            // shift $startHint lower
            
            if ($range->contains($startHint->getKey())) {
                $start = $startHint;
                
            }
            $iterator->setDirection(KeyReader::DIRECTION_BACKWARD);
            foreach ($iterator as $result) {
                // Skip everything which is too big
                if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) {
                    continue;
                    
                }
                
                // shift the start left until no more key is included
                if ($range->contains($result->getKey())) {
                    $start = $result;
                    
                } else {
                    break;
                    
                }
            }
            
        }
        if (is_null($start)) {
            return new RangeIterator($iterator, Range::getEmptyRange());

        }
        
        $iterator = $this->getIterator();
        $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY);
        return new RangeIterator($iterator, $range);
    }
646571
@Override
	public Iterator<Integer> iterator() {
		final IntIterator under = this.getIntIterator();
		return new Iterator<Integer>() {
			@Override
			public boolean hasNext() {
				return under.hasNext();
			}

			@Override
			public Integer next() {
				return new Integer(under.next());
			}

			@Override
			public void remove() {
				throw new UnsupportedOperationException(
						"bitsets do not support remove");
			}

		};
	}
282234
@Override
    public StateIdsBuilder append(final String stateToken, final StateRange range) {
        return doAppend(Collections.singletonList(new StateId(stateToken, range)));
    }
1305628
public static <C extends Comparable> RangeTree<C> create(final Iterable<Range<C>> ranges) {
        return new RangeList<C>(ranges);
    }
70350
@SuppressWarnings("unchecked")
    public static List<Float> getAt(float[] array, ObjectRange range) {
        return primitiveArrayGet(array, range);
    }
1111859
public static String getAt(String text, Range range) {
        RangeInfo info = subListBorders(text.length(), range);
        String answer = text.substring(info.from, info.to);
        if (info.reverse) {
            answer = reverse(answer);
        }
        return answer;
    }
1206962
public static List getAt(Matcher self, Collection indices) {
        List result = new ArrayList();
        for (Object value : indices) {
            if (value instanceof Range) {
                result.addAll(getAt(self, (Range) value));
            } else {
                int idx = DefaultTypeTransformation.intUnbox(value);
                result.add(getAt(self, idx));
            }
        }
        return result;
    }
983311
public Query range(ByteStringRange range) {
    RowRange.Builder rangeBuilder = RowRange.newBuilder();

    switch (range.getStartBound()) {
      case OPEN:
        rangeBuilder.setStartKeyOpen(range.getStart());
        break;
      case CLOSED:
        rangeBuilder.setStartKeyClosed(range.getStart());
        break;
      case UNBOUNDED:
        rangeBuilder.clearStartKey();
        break;
      default:
        throw new IllegalStateException("Unknown start bound: " + range.getStartBound());
    }

    switch (range.getEndBound()) {
      case OPEN:
        rangeBuilder.setEndKeyOpen(range.getEnd());
        break;
      case CLOSED:
        rangeBuilder.setEndKeyClosed(range.getEnd());
        break;
      case UNBOUNDED:
        rangeBuilder.clearEndKey();
        break;
      default:
        throw new IllegalStateException("Unknown end bound: " + range.getEndBound());
    }

    builder.getRowsBuilder().addRowRanges(rangeBuilder.build());

    return this;
  }
878147
private List<String> extractRanges(String range) {
		List<String> ranges;
		String[] rangeSpl = range.split(",");

		// Recent versions of scop always specify a chain, so no processing is needed
		if(scopVersion.compareTo("1.73") < 0 ) {
			for(int i=0; i<rangeSpl.length;i++) {
				String subRange = rangeSpl[i];

				// Allow single-chains, as well as the '-' special case
				if(subRange.length()<2) {
					continue;
				}

				// Allow explicit chain syntax
				if(subRange.charAt(1) != ':') {
					// Early versions sometimes skip the chain identifier for single-chain domains
					// Indicate this with a chain "_"
					rangeSpl[i] = "_:"+subRange;
				}
			}
		}
		ranges = Arrays.asList(rangeSpl);
		return ranges;
	}
555636
public boolean hasIntersection(final Range range) {
		return Math.max(this.start, range.start) <= Math.min(this.end, range.end);
	}
1107988
public static CharSequence getAt(CharSequence text, IntRange range) {
        return getAt(text, (Range) range);
    }
185161
public static IdRange parseRange(String range) {
        int pos = range.indexOf(':');
        try {
            if (pos == -1) {
                long value = parseLong(range);
                return new IdRange(value);
            } else {
                long lowVal = parseLong(range.substring(0, pos));
                long highVal = parseLong(range.substring(pos + 1));
                return new IdRange(lowVal, highVal);
            }
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid message set " + range);
        }
    }