Complete disaster-recovery snapshot: engine/game source, game data assets, VC6 toolchain + DX SDKs, build outputs, deployed game, and _UNUSED archive. Large binaries in Git LFS; text preserved byte-for-byte (core.autocrlf=false, no eol attributes). See RECOVERY.md for the one-clone rebuild procedure.
124 lines
1.9 KiB
C++
124 lines
1.9 KiB
C++
// vector standard header
|
|
|
|
#pragma once
|
|
|
|
#ifndef _TESTHPP_
|
|
#define _TESTHPP_
|
|
|
|
template<class _Type>
|
|
class my_vector
|
|
{
|
|
private:
|
|
_Type *m_Front;
|
|
_Type *m_Tail;
|
|
_Type *m_End;
|
|
|
|
int m_grow_size;
|
|
|
|
public:
|
|
my_vector (int growsize=1)
|
|
{
|
|
m_Front = m_Tail = m_End;
|
|
m_grow_size = growsize;
|
|
}
|
|
~my_vector (void)
|
|
{
|
|
delete m_Front;
|
|
m_Front = m_Tail = m_End;
|
|
}
|
|
|
|
_Type& at (int index)
|
|
{
|
|
assert (index>=0);
|
|
assert (index < (m_Tail - m_Front));
|
|
return m_Front[index];
|
|
}
|
|
const _Type& at (int index) const
|
|
{
|
|
assert (index>=0);
|
|
assert (index < (m_Tail - m_Front));
|
|
return m_Front[index];
|
|
}
|
|
_Type& operator[] (int index)
|
|
{
|
|
assert (index>=0);
|
|
assert (index < (m_Tail - m_Front));
|
|
return m_Front[index];
|
|
}
|
|
|
|
const _Type& operator[] (int index) const
|
|
{
|
|
assert (index>=0);
|
|
assert (index < (m_Tail - m_Front));
|
|
return m_Front[index];
|
|
}
|
|
|
|
|
|
void clear (void)
|
|
{
|
|
erase (0,size);
|
|
}
|
|
bool empty (void)
|
|
{
|
|
return m_Front == m_Tail;
|
|
}
|
|
void erase (int index)
|
|
{
|
|
int i,count;
|
|
|
|
assert (index>=0);
|
|
assert (index < (m_Tail - m_Front));
|
|
count = m_Tail - m_Start;
|
|
for (i=index;i<count;i++)
|
|
{
|
|
m_Front[i] = m_Front[i+1];
|
|
}
|
|
m_Front[count].~_Type ();
|
|
m_Tail--;
|
|
}
|
|
|
|
void pop_back (void)
|
|
{
|
|
m_Tail->~_Type ();
|
|
m_Tail--;
|
|
}
|
|
void push_back (const _Type& element)
|
|
{
|
|
if (m_Tail == m_End)
|
|
{
|
|
reserve ((m_Tail - m_Front)+m_grow_size);
|
|
}
|
|
m_Tail++;
|
|
*m_Tail = element;
|
|
}
|
|
void reserve (int amount)
|
|
{
|
|
if (amount > (m_End-m_Front))
|
|
{
|
|
_Type *temp,*cur;
|
|
int i,count;
|
|
|
|
temp = new _Type[amount];
|
|
count = m_Tail - m_Front;
|
|
|
|
cur = temp;
|
|
for (i=0;i<count;i++)
|
|
{
|
|
*cur = m_Front[i];
|
|
cur++;
|
|
}
|
|
delete m_Front;
|
|
m_Front = temp;
|
|
m_Tail = m_Front+count;
|
|
m_End = temp+amount;
|
|
}
|
|
}
|
|
int size (void) const
|
|
{
|
|
return m_Tail - m_Front;
|
|
}
|
|
};
|
|
|
|
#endif /* _TESTHPP_ */
|
|
|