Here you can find the source of flipBitmapRange(long[] bitmap, int start, int end)
Parameter | Description |
---|---|
bitmap | array of words to be modified |
start | first index to be modified (inclusive) |
end | last index to be modified (exclusive) |
public static void flipBitmapRange(long[] bitmap, int start, int end)
//package com.java2s; /*/*from w w w . ja v a2s . c o m*/ * (c) the authors Licensed under the Apache License, Version 2.0. */ public class Main { /** * flip bits at start, start+1,..., end-1 * * @param bitmap array of words to be modified * @param start first index to be modified (inclusive) * @param end last index to be modified (exclusive) */ public static void flipBitmapRange(long[] bitmap, int start, int end) { if (start == end) { return; } int firstword = start / 64; int endword = (end - 1) / 64; bitmap[firstword] ^= ~(~0L << start); for (int i = firstword; i < endword; i++) { bitmap[i] = ~bitmap[i]; } bitmap[endword] ^= ~0L >>> -end; } }