⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qarray.h

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 H
字号:
#ifndef __QARRAY_H#define __QARRAY_H#include <sys/types.h>template <class T>class QArray { protected://  T m_Temp;  unsigned char * m_pBuffer;  int m_nSize ; public:  QArray() { m_pBuffer =0; m_nSize =0;  }  QArray(int sz) { m_pBuffer =0; m_nSize =0; resize(sz); }  unsigned int size() { return (unsigned int)m_nSize; }  bool fill(const T & v, int newsize=-1)  {    unsigned int index = 0;    if(newsize > 0)      resize(newsize);    while(size() > index)      (*this)[index++] = v;    return true;  }  QArray<T> copy() const { return *this; }  void resize(int size)    {      unsigned char * b;      if(m_nSize < size) {	b = new unsigned char[size * sizeof(T)];	memcpy(b, m_pBuffer, m_nSize * sizeof(T));	delete [] m_pBuffer;	m_pBuffer = b;	m_nSize = size;      }     }  T  & operator[](int index)    {       if(index >= (int)size())	resize(index + 10);      return (T&)*(T*)(m_pBuffer + (sizeof(T) * index));    }};#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -