)
{
// Sanity checks
- bear::DASSERT(0 < uiStartSize);
- bear::DASSERT(1 < uiSizeMultiplier);
+ BEAR_DASSERT(0 < uiStartSize);
+ BEAR_DASSERT(1 < uiSizeMultiplier);
m_uiStartSize = uiStartSize;
m_uiSizeMultiplier = uiSizeMultiplier;
m_uiAllocated = 0;
// If this fires you have memory leaks
- bear::DASSERT(NULL == m_pArrayItems);
+ BEAR_DASSERT(NULL == m_pArrayItems);
m_pArrayItems = NULL;
m_pHead = NULL;
allocForce(uiSize);
}
- bear::DASSERT(m_uiAllocated >= uiSize);
+ BEAR_DASSERT(m_uiAllocated >= uiSize);
// TODO: return error when new fails
}
}
// Sanity checks
- bear::DASSERT(uiSize == getLength());
- bear::DASSERT(uiSize == m_uiAllocated);
+ BEAR_DASSERT(uiSize == getLength());
+ BEAR_DASSERT(uiSize == m_uiAllocated);
}
template < class Item >
{
if ( NULL == m_pHead )
{
- bear::DASSERT(NULL == m_pTail);
+ BEAR_DASSERT(NULL == m_pTail);
return true;
}
else
{
- bear::DASSERT(NULL != m_pTail);
+ BEAR_DASSERT(NULL != m_pTail);
return false;
}
}
template < class Item >
+unsigned int bear::Array<Item>::getLength() const
+{
+ if ( isEmpty() )
+ {
+ return 0;
+ }
+ else
+ {
+ return mod( m_pTail - m_pHead, m_uiAllocated ) + 1;
+ }
+}
+
+template < class Item >
const Item& bear::Array<Item>::getAt(unsigned int uiIndex) const
{
// This is very bad. Fix your code
- DASSERT(uiIndex < getLength());
+ BEAR_DASSERT(uiIndex < getLength());
return *withinBounds( m_pHead + uiIndex, m_pArrayItems, m_pArrayItems + m_uiAllocated );
}
const Item& bear::Array<Item>::getFront() const
{
// This is very bad. Fix your code
- bear::DASSERT(!isEmpty());
+ BEAR_DASSERT(!isEmpty());
// sanity check
- //bear::DASSERT(m_pHead <= m_uiAllocated);
+ //BEAR_DASSERT(m_pHead <= m_uiAllocated);
return *m_pHead;
}
const Item& bear::Array<Item>::getBack() const
{
// This is very bad. Fix your code
- bear::DASSERT(!isEmpty());
+ BEAR_DASSERT(!isEmpty());
// sanity check
- //bear::DASSERT(m_pTail <= m_uiAllocated);
+ //BEAR_DASSERT(m_pTail <= m_uiAllocated);
return *m_pTail;
}
template < class Item >
void bear::Array<Item>::popFront()
{
- bear::DASSERT(!isEmpty());
+ BEAR_DASSERT(!isEmpty());
if( m_pHead == m_pTail )
{
template < class Item >
void bear::Array<Item>::popBack()
{
- bear::DASSERT(!isEmpty());
+ BEAR_DASSERT(!isEmpty());
if( m_pHead == m_pTail )
{
}
}
-
-template < class Item >
-unsigned int bear::Array<Item>::getLength() const
-{
- if ( isEmpty() )
- {
- return 0;
- }
- else
- {
- return mod( m_pTail - m_pHead, m_uiAllocated ) + 1;
- }
-}
-
template < class Item >
void bear::Array<Item>::allocFirstTime(unsigned int uiSize)
{
// santiy checks
- bear::DASSERT(0 == m_uiAllocated);
- bear::DASSERT(NULL == m_pArrayItems);
- bear::DASSERT(isEmpty());
+ BEAR_DASSERT(0 == m_uiAllocated);
+ BEAR_DASSERT(NULL == m_pArrayItems);
+ BEAR_DASSERT(isEmpty());
if(0 < uiSize)
{
{
unsigned int uiSizeNeeded = (0 == m_uiAllocated) ? m_uiStartSize : m_uiAllocated;
- bear::DASSERT(0 < m_uiStartSize);
- bear::DASSERT(1 < m_uiSizeMultiplier);
+ BEAR_DASSERT(0 < m_uiStartSize);
+ BEAR_DASSERT(1 < m_uiSizeMultiplier);
while ( uiSizeNeeded < uiSize )
{
}
// santiy checks
- bear::DASSERT(pNewTail == getPrevTail(pNewItem, uiNewAllocated, pNewArrayItems));
- bear::DASSERT(pOldTail == getPrevTail(pOldItem, uiOldAllocated, pOldArrayItems));
+ BEAR_DASSERT(pNewTail == getPrevTail(pNewItem, uiNewAllocated, pNewArrayItems));
+ BEAR_DASSERT(pOldTail == getPrevTail(pOldItem, uiOldAllocated, pOldArrayItems));
delete pOldArrayItems;
pOldArrayItems = NULL;
Item* pBoundedValue = reinterpret_cast<Item*>(uiBoundedValue);
// sanity checks
- bear::DASSERT(pMinBound <= pBoundedValue);
- bear::DASSERT(pMaxBound > pBoundedValue);
+ BEAR_DASSERT(pMinBound <= pBoundedValue);
+ BEAR_DASSERT(pMaxBound > pBoundedValue);
return pBoundedValue;
}