MATH-552
Fixed bug in "MultidimensionalCounter". Thanks to James Bence. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1087637 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3f53445d11
commit
368f17d194
|
@ -234,13 +234,7 @@ public class MultidimensionalCounter implements Iterable<Integer> {
|
|||
indices[i] = idx;
|
||||
}
|
||||
|
||||
int idx = 1;
|
||||
while (count < index) {
|
||||
count += idx;
|
||||
++idx;
|
||||
}
|
||||
--idx;
|
||||
indices[last] = idx;
|
||||
indices[last] = index - count;
|
||||
|
||||
return indices;
|
||||
}
|
||||
|
|
|
@ -52,6 +52,9 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
If the output is not quite correct, check for invisible trailing spaces!
|
||||
-->
|
||||
<release version="3.0" date="TBD" description="TBD">
|
||||
<action dev="erans" type="fix" issue="MATH-552" due-to="James Bence">
|
||||
Fixed bug in "MultidimensionalCounter".
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-423" due-to="Gilles Sadowski" >
|
||||
All unit tests have been converted to Junit 4. They need at least Junit 4.5 to run
|
||||
(the ant and maven build systems are currently set to use Junit 4.8.2)
|
||||
|
|
|
@ -121,20 +121,32 @@ public class MultidimensionalCounterTest {
|
|||
|
||||
@Test
|
||||
public void testIterationConsistency() {
|
||||
final MultidimensionalCounter c = new MultidimensionalCounter(2, 3, 2);
|
||||
final MultidimensionalCounter c = new MultidimensionalCounter(2, 3, 4);
|
||||
final int[][] expected = new int[][] {
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 1 },
|
||||
{ 0, 0, 2 },
|
||||
{ 0, 0, 3 },
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 1, 1 },
|
||||
{ 0, 1, 2 },
|
||||
{ 0, 1, 3 },
|
||||
{ 0, 2, 0 },
|
||||
{ 0, 2, 1 },
|
||||
{ 0, 2, 2 },
|
||||
{ 0, 2, 3 },
|
||||
{ 1, 0, 0 },
|
||||
{ 1, 0, 1 },
|
||||
{ 1, 0, 2 },
|
||||
{ 1, 0, 3 },
|
||||
{ 1, 1, 0 },
|
||||
{ 1, 1, 1 },
|
||||
{ 1, 1, 2 },
|
||||
{ 1, 1, 3 },
|
||||
{ 1, 2, 0 },
|
||||
{ 1, 2, 1 }
|
||||
{ 1, 2, 1 },
|
||||
{ 1, 2, 2 },
|
||||
{ 1, 2, 3 }
|
||||
};
|
||||
|
||||
final int totalSize = c.getSize();
|
||||
|
|
Loading…
Reference in New Issue