Skip to content
Browse files

buffer length of each subbuffer was not handled correctly.

  • Loading branch information...
1 parent be9d0a3 commit 6052865e33247140f664b134f0db782810c6a4e1 Marije Baalman committed Feb 16, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 app/src/com/steim/nescivi/android/gvb/CircularFloatArrayBuffer2.java
View
12 app/src/com/steim/nescivi/android/gvb/CircularFloatArrayBuffer2.java
@@ -25,15 +25,15 @@ public CircularFloatArrayBuffer2(int dim, int size) {
}
public void add(float elem[]) {
- int victim = (mNewestElement + 1) % mBuffer.length;
+ int victim = (mNewestElement + 1) % mBuffer[0].length;
for ( int i=0; i<mDim; i++ ){
mBuffer[i][victim] = elem[i];
}
mNewestElement = victim;
- if (mSize < mBuffer.length) {
+ if (mSize < mBuffer[0].length) {
mSize++;
}
@@ -50,11 +50,11 @@ public int getDim() {
public float[][] getContents() {
float result[][] = new float[mDim][mSize];
- if (mSize == mBuffer.length) {
- int oldestElement = (mNewestElement + 1) % mBuffer.length;
+ if (mSize == mBuffer[0].length) {
+ int oldestElement = (mNewestElement + 1) % mBuffer[0].length;
for ( int j=0; j<mDim; j++ ){
- for (int i = 0; i < result.length; i++) {
+ for (int i = 0; i < result[j].length; i++) {
result[j][i] = (float) mBuffer[j][oldestElement];
if (++oldestElement == mBuffer.length)
@@ -65,7 +65,7 @@ public int getDim() {
else {
for ( int j=0; j<mDim; j++ ){
// special case here: buffer is not filled yet (so just dump the buffer)
- for (int i = 0; i < result.length; i++) {
+ for (int i = 0; i < result[j].length; i++) {
result[j][i] = (float) mBuffer[j][i];
}
}

0 comments on commit 6052865

Please sign in to comment.
Something went wrong with that request. Please try again.