示例#1
0
 /**
  * Instance constructor.
  */
 public ObjPositionSamples(int _W_)
 {
     samples = new ObjPositionSample[_W_];
     for (int i = 0; i < _W_; i++)
     {
         samples[i] = new ObjPositionSample(0, 0);
     }
     W = _W_;
     lastInsertIndex = W - 1;
     oldestIndex     = 0;
 }
示例#2
0
    /**
     * This method adds a PositionSample to the set of samples.
     */
    public void AddSample(ObjPositionSample _s_)
    {
        //calculate the index to insert the sample into
        int insertIndex = lastInsertIndex + 1;

        if (insertIndex == W)
        {
            insertIndex = 0;
        }

        //insert the sample into the array
        samples [insertIndex] = _s_;

        //update the last inserted sample
        lastInsertIndex = insertIndex;

        //update the oldest inserted sample
        oldestIndex = lastInsertIndex + 1;
        if (oldestIndex == W || samples[oldestIndex] == null)
        {
            oldestIndex = 0;
        }
    }