package app.brest.utils;

import java.util.ArrayList;

import app.brest.utils.geometry.Point;


public class SlideBuffer {
    private float mData;
    private int mSize;
    private int mHead;

    public SlideBuffer(int size)
    {
        mData = 0;
        mSize = 0;
        mHead =0;
    }

    public void enqueue(float val)
    {
        mData= mData + 0.5f*(val-mData);
    }

    public float average()
    {
        return mData;
    }

}

/*
package app.brest.utils;

import java.util.ArrayList;

public class SlideBuffer {
    private float[] mData;
    private float[] mTmp;
    private int mSize;
    private int mHead;

    public SlideBuffer(int size)
    {
        mData = new float[size];
        mTmp = new float[size];
        mSize = 0;
        mHead =0;
    }

    public void enqueue(float val)
    {

        mData[mHead] = val;
        mHead=(mHead+1)%mData.length;
        if(mSize<mData.length) mSize++;
    }

    private float[] exponentialSmoothing( float[] input, float[] output, float alpha ) {
        if ( output == null )
            return input;
        for ( int i=0; i<input.length; i++ ) {
            output[i] = output[i] + alpha * (input[i] - output[i]);
        }
        return output;
    }

    public float average()
    {

            float acc=0;
            for(int i=0; i<mSize; i++)
                acc+=mData[i];
            return acc/mSize;
    }



}
*/
