Skip to content

Commit 053916d

Browse files
committed
simplifying BitArray.setBulk
1 parent 9859cfd commit 053916d

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

Source/lib/common/BitArray.cs

+5-10
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,12 @@ public int getNextUnset(int from)
189189
return result > size ? size : result;
190190
}
191191

192-
/// <summary> Sets a block of 32 bits, starting at bit i.
193-
///
194-
/// </summary>
195-
/// <param name="i">first bit to set
196-
/// </param>
197-
/// <param name="newBits">the new value of the next 32 bits. Note again that the least-significant bit
198-
/// corresponds to bit i, the next-least-significant to i+1, and so on.
199-
/// </param>
200-
public void setBulk(int i, int newBits)
192+
/// <summary> Sets a block of 32 bits, starting at bit i.</summary>
193+
/// <param name="blockIndex">index position of the new 32 bit block</param>
194+
/// <param name="newBits">the new value of the next 32 bits.</param>
195+
public void setBulk(int blockIndex, int newBits)
201196
{
202-
bits[i >> 5] = newBits;
197+
bits[blockIndex] = newBits;
203198
}
204199

205200
/// <summary>

Source/lib/common/BitMatrix.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public BitArray getRow(int y, BitArray row)
391391
int offset = y * rowSize;
392392
for (int x = 0; x < rowSize; x++)
393393
{
394-
row.setBulk(x << 5, bits[offset + x]);
394+
row.setBulk(x, bits[offset + x]);
395395
}
396396
return row;
397397
}

Source/test/src/common/BitArrayTestCase.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,11 @@ public void testGetNextSet5()
148148
}
149149
}
150150

151-
152151
[Test]
153152
public void testSetBulk()
154153
{
155154
BitArray array = new BitArray(64);
156-
array.setBulk(32, -65536);
155+
array.setBulk(1, -65536);
157156
for (int i = 0; i < 48; i++)
158157
{
159158
Assert.IsFalse(array[i]);

0 commit comments

Comments
 (0)