[Suspected bug] CQueue::CopyTo error

 

Hi,

I've found that CopyTo method has a mistake

Original code is :

template<typename T>

int CQueue::CopyTo(T &dst_array[],const int dst_start=0)

  {

//--- resize array

   if((dst_start+m_size)>ArraySize(dst_array))

      if(ArrayResize(dst_array,dst_start+m_size)<0)

         return(0);

//--- copy queue elements from head to tail

   if(m_tail >= m_head)

      return(ArrayCopy(dst_array,m_array,dst_start,m_head,m_size));

//--- copy queue elements from head to end

   int num_copied=ArrayCopy(dst_array,m_array,dst_start,m_head,m_size-m_head);

//--- copy queue elements from beginning to tail

   num_copied+=ArrayCopy(dst_array,m_array,dst_start+num_copied,0,m_tail);

//--- return number of copied elements

   return(num_copied);

  }


When CQueue is full it returns less elements than it actually has:

Error is in 

if(m_tail >= m_head)

Changing it to

if(m_tail > m_head)
makes it work as expected.
Reason: