Upgraded CVector

This commit is contained in:
David Anderson 2004-09-10 03:31:36 +00:00
parent 267db7cc2b
commit a055d3d373
4 changed files with 43 additions and 33 deletions

View File

@ -32,6 +32,8 @@
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
@ -284,7 +286,7 @@ public:
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
ASSERT(0);
assert(0);
return iterator(m_Data + pos);
}
@ -331,7 +333,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -340,7 +342,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -359,7 +361,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -368,7 +370,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -377,7 +379,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
@ -386,7 +388,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}

View File

@ -32,6 +32,8 @@
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
@ -284,7 +286,7 @@ public:
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
ASSERT(0);
assert(0);
return iterator(m_Data + pos);
}
@ -331,7 +333,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -340,7 +342,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -359,7 +361,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -368,7 +370,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -377,7 +379,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
@ -386,7 +388,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}

View File

@ -32,6 +32,8 @@
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
@ -76,7 +78,7 @@ template <class T> class CVector
delete [] m_Data;
}
if (m_Size < size)
m_CurrentUsedSize = size;
m_CurrentSize = size;
m_Data = newData;
m_Size = size;
return true;
@ -284,7 +286,7 @@ public:
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
ASSERT(0);
assert(0);
return iterator(m_Data + pos);
}
@ -331,7 +333,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -340,7 +342,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -359,7 +361,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -368,7 +370,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -377,7 +379,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
@ -386,7 +388,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}

View File

@ -32,6 +32,8 @@
#ifndef __CVECTOR_H__
#define __CVECTOR_H__
#include <assert.h>
// Vector
template <class T> class CVector
{
@ -76,7 +78,7 @@ template <class T> class CVector
delete [] m_Data;
}
if (m_Size < size)
m_CurrentUsedSize = size;
m_CurrentSize = size;
m_Data = newData;
m_Size = size;
return true;
@ -90,6 +92,7 @@ protected:
T *m_Data;
size_t m_Size;
size_t m_CurrentUsedSize;
size_t m_CurrentSize;
public:
class iterator
{
@ -283,7 +286,7 @@ public:
iterator iterAt(size_t pos)
{
if (pos > m_CurrentUsedSize)
ASSERT(0);
assert(0);
return iterator(m_Data + pos);
}
@ -330,7 +333,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
// ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -339,7 +342,7 @@ public:
{
if (pos > m_CurrentUsedSize)
{
// ASSERT(0);
assert(0);
}
return m_Data[pos];
}
@ -358,7 +361,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -367,7 +370,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[0];
}
@ -376,7 +379,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
@ -385,7 +388,7 @@ public:
{
if (m_CurrentUsedSize < 1)
{
ASSERT(0);
assert(0);
}
return m_Data[m_CurrentUsedSize - 1];
}
@ -397,7 +400,7 @@ public:
if (where != m_Data)
--where;
// validate iter
if (where < m_Data || where >= (m_Data + m_CurrentSize))
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
return false;
++m_CurrentUsedSize;
@ -415,7 +418,7 @@ public:
void erase(iterator where)
{
// validate iter
if (where < m_Data || where >= (m_Data + m_CurrentSize))
if (where < m_Data || where >= (m_Data + m_CurrentUsedSize))
return false;
if (m_CurrentUsedSize > 1)
@ -438,3 +441,4 @@ public:
};
#endif // __CVECTOR_H__