*
marcomoeller@googlemail.com:
> hi all,
>
> i need for an project an "finiteQue" class. what save the last N
> pushed values and forgot the other ones..
>
> like this:
> template <class T,std::size_t N>
> class FinitQue {
> public:
> inline void push_front(const T newDat);
> inline T get(std::size_t idx) const ;
> inline T operator[](std::size_t idx);
> inline T get_back() const;
> inline T get_front() const;
> inline std::size_t getAmount() const;
> inline std::size_t getSize() const;
> inline bool operator==(const FinitQue<T,N> & h2) const;
> };
>
> Now I whant to give two different implementations, one for N == 1
> (data of type T) and one for N>=1 (Array of fix size)
>
> how to do this? it is REALY speed critical.. with dynamic memory the
> runtime of my simulation is going up by times 4!!!
You can specialize for N == 1,
template<class T>
class FinitQue<T, 1> { ... };
but why don't you use an array in all cases?
boost::array or whatever.
By the way, what's with the "get" prefixes and mix of naming
conventions? Makes me suspect Java background. What on Earth do you
expect the prefixes will do of good in C++?
Cheers,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?