Пример #1
0
Buffer<T,Allocator>::Buffer(CONST T* pData, SIZE_T N)
{
  m_pData = 0;
  m_Length = 0;

  Allocate(N);
  CopyObjects(m_pData, pData, N); 
}
Пример #2
0
VOID Buffer<T,Allocator>::Resize(SIZE_T N)
{
  SIZE_T NewLength = AllocateSize(N);
  T* pData = m_Allocator.New(NewLength);
  CopyObjects(pData, m_pData, Min(m_Length, NewLength));
  m_Allocator.Delete(m_pData);
  m_pData = pData;
  m_Length = NewLength;
}
Пример #3
0
VOID Queue<T,ElementTraits,ThreadingModel>::Enqueue( CONST T& Item )
{
  if (m_Tail < m_Head)
  {
    if (m_Head < m_Buffer.Length())
      m_Buffer[m_Head++] = Item;
    else
    {
      if (m_Tail > 0)
        m_Head = 0;
      else
      {
        if (m_Buffer.Length() < 16)
          m_Buffer.Resize( 16 );
        else
          m_Buffer.Resize( (SIZE_T)((FLOAT)(m_Buffer.Length()+1) * 1.5) );
      }
      m_Buffer[m_Head++] = Item;
    }
  }
  else if (m_Tail > m_Head)
    m_Buffer[m_Head++] = Item;
  else if (m_Tail == m_Head)
  {
    if (m_Tail == 0)
    {
      if (m_Buffer.Length() < 16)
        m_Buffer.Resize( 16 );
      m_Buffer[m_Head++] = Item;
    }
    else
    {
      SIZE_T TailSize = m_Buffer.Length() - m_Tail;
      Buffer<T> NewBuffer( (SIZE_T)((FLOAT)(m_Buffer.Length()+1) * 1.5) );
      CopyObjects( &NewBuffer[0] , &m_Buffer[m_Tail], TailSize );
      CopyObjects( &NewBuffer[TailSize] , &m_Buffer[0], m_Head );
      m_Tail = 0;
      m_Head = m_Buffer.Length();
      m_Buffer = NewBuffer;
      m_Buffer[m_Head++] = Item;
    }
  }
}
Пример #4
0
void appCopyPaste::CopyObject(const MenuObjC*     objData,
                              const AllocPageC*   objPageAllocator)
{
    if ((objData == 0) || (!objData->IsCopyable()))
        return;

    MenuObjArray objs(1);
    objs[0] = const_cast<MenuObjC*>(objData);
    CopyObjects(objs, objPageAllocator);
}
Пример #5
0
Buffer<T,Allocator>& Buffer<T,Allocator>::operator= (CONST Buffer& B)
{
  Allocate(B.Length());
  CopyObjects(m_pData, B.m_pData, m_Length);
  return *this;
}