#ifndef _REGRESSIONSTORAGE_HPP_
#define _REGRESSIONSTORAGE_HPP_

#include <deque>
#include <stdexcept>
#include "Vector.h"

namespace numeric {


class RegressionStorage
{
	private:
		std::vector< std::deque<Vector> > storagePit;
		unsigned capacity;

	public:
    RegressionStorage(unsigned K, unsigned _capacity)
    {
      storagePit = std::vector< std::deque<Vector> >(K,std::deque<Vector>(_capacity));
      capacity=_capacity;
    }

    Vector getLastHyperplan( unsigned K)
    {
    	return storagePit[K].front();
    }

		Vector getHyperplan( unsigned K, unsigned i)
    {
		 	if( i < capacity )
		   	return storagePit[K][i];
			else
			{
				throw std::out_of_range("index out of capacity");
				return Vector();
			}
    }

    void store( const Vector & b, unsigned K )
    {
      if( storagePit[K].size() >= capacity)
      {
      	storagePit[K].pop_back();
      }
			storagePit[K].push_front(b);
    }
};

}

#endif

