(svn r14949) -Cleanup: pointer coding style
This commit is contained in:
@@ -5,9 +5,9 @@
|
||||
#ifndef BINARYHEAP_HPP
|
||||
#define BINARYHEAP_HPP
|
||||
|
||||
//void* operator new (size_t size, void* p) {return p;}
|
||||
//void *operator new (size_t size, void *p) {return p;}
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||
//void operator delete (void* p, void* p2) {}
|
||||
//void operator delete (void *p, void *p2) {}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public:
|
||||
private:
|
||||
int m_size; ///< Number of items in the heap
|
||||
int m_max_size; ///< Maximum number of items the heap can hold
|
||||
ItemPtr* m_items; ///< The heap item pointers
|
||||
ItemPtr *m_items; ///< The heap item pointers
|
||||
|
||||
public:
|
||||
explicit CBinaryHeapT(int max_items = 102400)
|
||||
|
@@ -101,7 +101,7 @@ protected:
|
||||
}
|
||||
|
||||
/** initialize blob by attaching it to the given header followed by data */
|
||||
FORCEINLINE void Init(CHdr* hdr)
|
||||
FORCEINLINE void Init(CHdr *hdr)
|
||||
{
|
||||
ptr_u.m_pHdr_1 = &hdr[1];
|
||||
}
|
||||
@@ -144,13 +144,13 @@ public:
|
||||
};
|
||||
|
||||
/** return pointer to the first byte of data - non-const version */
|
||||
FORCEINLINE bitem_t* RawData()
|
||||
FORCEINLINE bitem_t *RawData()
|
||||
{
|
||||
return ptr_u.m_pData;
|
||||
}
|
||||
|
||||
/** return pointer to the first byte of data - const version */
|
||||
FORCEINLINE const bitem_t* RawData() const
|
||||
FORCEINLINE const bitem_t *RawData() const
|
||||
{
|
||||
return ptr_u.m_pData;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ public:
|
||||
|
||||
/** Reallocate if there is no free space for num_bytes bytes.
|
||||
* @return pointer to the new data to be added */
|
||||
FORCEINLINE bitem_t* MakeRawFreeSpace(bsize_t num_bytes)
|
||||
FORCEINLINE bitem_t *MakeRawFreeSpace(bsize_t num_bytes)
|
||||
{
|
||||
assert(num_bytes >= 0);
|
||||
bsize_t new_size = RawSize() + num_bytes;
|
||||
@@ -228,9 +228,9 @@ public:
|
||||
|
||||
/** Increase RawSize() by num_bytes.
|
||||
* @return pointer to the new data added */
|
||||
FORCEINLINE bitem_t* GrowRawSize(bsize_t num_bytes)
|
||||
FORCEINLINE bitem_t *GrowRawSize(bsize_t num_bytes)
|
||||
{
|
||||
bitem_t* pNewData = MakeRawFreeSpace(num_bytes);
|
||||
bitem_t *pNewData = MakeRawFreeSpace(num_bytes);
|
||||
RawSizeRef() += num_bytes;
|
||||
return pNewData;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ public:
|
||||
// ask allocation policy for some reasonable block size
|
||||
bsize_t alloc_size = AllocPolicy(min_alloc_size);
|
||||
// allocate new block
|
||||
CHdr* pNewHdr = RawAlloc(alloc_size);
|
||||
CHdr *pNewHdr = RawAlloc(alloc_size);
|
||||
// setup header
|
||||
pNewHdr->m_size = RawSize();
|
||||
pNewHdr->m_max_size = alloc_size - (sizeof(CHdr) + Ttail_reserve);
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
if (RawSize() > 0)
|
||||
memcpy(pNewHdr + 1, ptr_u.m_pData, pNewHdr->m_size);
|
||||
// replace our block with new one
|
||||
CHdr* pOldHdr = &Hdr();
|
||||
CHdr *pOldHdr = &Hdr();
|
||||
Init(pNewHdr);
|
||||
if (old_max_size > 0)
|
||||
RawFree(pOldHdr);
|
||||
@@ -289,13 +289,13 @@ public:
|
||||
}
|
||||
|
||||
/** all allocation should happen here */
|
||||
static FORCEINLINE CHdr* RawAlloc(bsize_t num_bytes)
|
||||
static FORCEINLINE CHdr *RawAlloc(bsize_t num_bytes)
|
||||
{
|
||||
return (CHdr*)MallocT<byte>(num_bytes);
|
||||
}
|
||||
|
||||
/** all deallocations should happen here */
|
||||
static FORCEINLINE void RawFree(CHdr* p)
|
||||
static FORCEINLINE void RawFree(CHdr *p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
@@ -370,26 +370,26 @@ public:
|
||||
}
|
||||
|
||||
/** Return pointer to the first data item - non-const version */
|
||||
FORCEINLINE Titem* Data()
|
||||
FORCEINLINE Titem *Data()
|
||||
{
|
||||
return (Titem*)Tbase::RawData();
|
||||
}
|
||||
|
||||
/** Return pointer to the first data item - const version */
|
||||
FORCEINLINE const Titem* Data() const
|
||||
FORCEINLINE const Titem *Data() const
|
||||
{
|
||||
return (const Titem*)Tbase::RawData();
|
||||
}
|
||||
|
||||
/** Return pointer to the idx-th data item - non-const version */
|
||||
FORCEINLINE Titem* Data(bsize_t idx)
|
||||
FORCEINLINE Titem *Data(bsize_t idx)
|
||||
{
|
||||
CheckIdx(idx);
|
||||
return (Data() + idx);
|
||||
}
|
||||
|
||||
/** Return pointer to the idx-th data item - const version */
|
||||
FORCEINLINE const Titem* Data(bsize_t idx) const
|
||||
FORCEINLINE const Titem *Data(bsize_t idx) const
|
||||
{
|
||||
CheckIdx(idx);
|
||||
return (Data() + idx);
|
||||
@@ -419,22 +419,22 @@ public:
|
||||
bsize_t old_size = Size();
|
||||
if (old_size > 0) {
|
||||
// destroy removed items;
|
||||
Titem* pI_last_to_destroy = Data(0);
|
||||
for (Titem* pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem_();
|
||||
Titem *pI_last_to_destroy = Data(0);
|
||||
for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem_();
|
||||
}
|
||||
Tbase::Free();
|
||||
}
|
||||
|
||||
/** Grow number of data items in Blob by given number - doesn't construct items */
|
||||
FORCEINLINE Titem* GrowSizeNC(bsize_t num_items)
|
||||
FORCEINLINE Titem *GrowSizeNC(bsize_t num_items)
|
||||
{
|
||||
return (Titem*)Tbase::GrowRawSize(num_items * Titem_size);
|
||||
}
|
||||
|
||||
/** Grow number of data items in Blob by given number - constructs new items (using Titem_'s default constructor) */
|
||||
FORCEINLINE Titem* GrowSizeC(bsize_t num_items)
|
||||
FORCEINLINE Titem *GrowSizeC(bsize_t num_items)
|
||||
{
|
||||
Titem* pI = GrowSizeNC(num_items);
|
||||
Titem *pI = GrowSizeNC(num_items);
|
||||
for (bsize_t i = num_items; i > 0; i--, pI++) new (pI) Titem();
|
||||
}
|
||||
|
||||
@@ -446,34 +446,34 @@ public:
|
||||
assert(num_items <= old_size);
|
||||
bsize_t new_size = (num_items <= old_size) ? (old_size - num_items) : 0;
|
||||
// destroy removed items;
|
||||
Titem* pI_last_to_destroy = Data(new_size);
|
||||
for (Titem* pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem();
|
||||
Titem *pI_last_to_destroy = Data(new_size);
|
||||
for (Titem *pI = Data(old_size - 1); pI >= pI_last_to_destroy; pI--) pI->~Titem();
|
||||
// remove them
|
||||
Tbase::ReduceRawSize(num_items * Titem_size);
|
||||
}
|
||||
|
||||
/** Append one data item at the end (calls Titem_'s default constructor) */
|
||||
FORCEINLINE Titem* AppendNew()
|
||||
FORCEINLINE Titem *AppendNew()
|
||||
{
|
||||
Titem& dst = *GrowSizeNC(1); // Grow size by one item
|
||||
Titem* pNewItem = new (&dst) Titem(); // construct the new item by calling in-place new operator
|
||||
Titem *pNewItem = new (&dst) Titem(); // construct the new item by calling in-place new operator
|
||||
return pNewItem;
|
||||
}
|
||||
|
||||
/** Append the copy of given item at the end of Blob (using copy constructor) */
|
||||
FORCEINLINE Titem* Append(const Titem& src)
|
||||
FORCEINLINE Titem *Append(const Titem& src)
|
||||
{
|
||||
Titem& dst = *GrowSizeNC(1); // Grow size by one item
|
||||
Titem* pNewItem = new (&dst) Titem(src); // construct the new item by calling in-place new operator with copy ctor()
|
||||
Titem *pNewItem = new (&dst) Titem(src); // construct the new item by calling in-place new operator with copy ctor()
|
||||
return pNewItem;
|
||||
}
|
||||
|
||||
/** Add given items (ptr + number of items) at the end of blob */
|
||||
FORCEINLINE Titem* Append(const Titem* pSrc, bsize_t num_items)
|
||||
FORCEINLINE Titem *Append(const Titem *pSrc, bsize_t num_items)
|
||||
{
|
||||
Titem* pDst = GrowSizeNC(num_items);
|
||||
Titem* pDstOrg = pDst;
|
||||
Titem* pDstEnd = pDst + num_items;
|
||||
Titem *pDst = GrowSizeNC(num_items);
|
||||
Titem *pDstOrg = pDst;
|
||||
Titem *pDstEnd = pDst + num_items;
|
||||
while (pDst < pDstEnd) new (pDst++) Titem(*(pSrc++));
|
||||
return pDstOrg;
|
||||
}
|
||||
@@ -483,14 +483,14 @@ public:
|
||||
{
|
||||
CheckIdx(idx);
|
||||
// destroy removed item
|
||||
Titem* pRemoved = Data(idx);
|
||||
Titem *pRemoved = Data(idx);
|
||||
RemoveBySwap(pRemoved);
|
||||
}
|
||||
|
||||
/** Remove item given by pointer replacing it by the last item and reducing the size by one */
|
||||
FORCEINLINE void RemoveBySwap(Titem* pItem)
|
||||
FORCEINLINE void RemoveBySwap(Titem *pItem)
|
||||
{
|
||||
Titem* pLast = Data(Size() - 1);
|
||||
Titem *pLast = Data(Size() - 1);
|
||||
assert(pItem >= Data() && pItem <= pLast);
|
||||
// move last item to its new place
|
||||
if (pItem != pLast) {
|
||||
@@ -505,7 +505,7 @@ public:
|
||||
|
||||
/** Ensures that given number of items can be added to the end of Blob. Returns pointer to the
|
||||
* first free (unused) item */
|
||||
FORCEINLINE Titem* MakeFreeSpace(bsize_t num_items)
|
||||
FORCEINLINE Titem *MakeFreeSpace(bsize_t num_items)
|
||||
{
|
||||
return (Titem*)Tbase::MakeRawFreeSpace(num_items * Titem_size);
|
||||
}
|
||||
|
@@ -23,11 +23,11 @@ public:
|
||||
|
||||
protected:
|
||||
/** here we hold our pointer to the target */
|
||||
Tcls* m_pT;
|
||||
Tcls *m_pT;
|
||||
|
||||
public:
|
||||
/** default (NULL) construct or construct from a raw pointer */
|
||||
FORCEINLINE CCountedPtr(Tcls* pObj = NULL) : m_pT(pObj) {AddRef();};
|
||||
FORCEINLINE CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();};
|
||||
|
||||
/** copy constructor (invoked also when initializing from another smart ptr) */
|
||||
FORCEINLINE CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();};
|
||||
@@ -41,13 +41,13 @@ protected:
|
||||
|
||||
public:
|
||||
/** release smart pointer (and decrement ref count) if not null */
|
||||
FORCEINLINE void Release() {if (m_pT != NULL) {Tcls* pT = m_pT; m_pT = NULL; pT->Release();}}
|
||||
FORCEINLINE void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}
|
||||
|
||||
/** dereference of smart pointer - const way */
|
||||
FORCEINLINE const Tcls* operator -> () const {assert(m_pT != NULL); return m_pT;};
|
||||
FORCEINLINE const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;};
|
||||
|
||||
/** dereference of smart pointer - non const way */
|
||||
FORCEINLINE Tcls* operator -> () {assert(m_pT != NULL); return m_pT;};
|
||||
FORCEINLINE Tcls *operator -> () {assert(m_pT != NULL); return m_pT;};
|
||||
|
||||
/** raw pointer casting operator - const way */
|
||||
FORCEINLINE operator const Tcls*() const {assert(m_pT == NULL); return m_pT;}
|
||||
@@ -59,13 +59,13 @@ public:
|
||||
FORCEINLINE Tcls** operator &() {assert(m_pT == NULL); return &m_pT;}
|
||||
|
||||
/** assignment operator from raw ptr */
|
||||
FORCEINLINE CCountedPtr& operator = (Tcls* pT) {Assign(pT); return *this;}
|
||||
FORCEINLINE CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;}
|
||||
|
||||
/** assignment operator from another smart ptr */
|
||||
FORCEINLINE CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;}
|
||||
|
||||
/** assignment operator helper */
|
||||
FORCEINLINE void Assign(Tcls* pT);
|
||||
FORCEINLINE void Assign(Tcls *pT);
|
||||
|
||||
/** one way how to test for NULL value */
|
||||
FORCEINLINE bool IsNull() const {return m_pT == NULL;}
|
||||
@@ -77,19 +77,19 @@ public:
|
||||
//FORCEINLINE bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;}
|
||||
|
||||
/** assign pointer w/o incrementing ref count */
|
||||
FORCEINLINE void Attach(Tcls* pT) {Release(); m_pT = pT;}
|
||||
FORCEINLINE void Attach(Tcls *pT) {Release(); m_pT = pT;}
|
||||
|
||||
/** detach pointer w/o decrementing ref count */
|
||||
FORCEINLINE Tcls* Detach() {Tcls* pT = m_pT; m_pT = NULL; return pT;}
|
||||
FORCEINLINE Tcls *Detach() {Tcls *pT = m_pT; m_pT = NULL; return pT;}
|
||||
};
|
||||
|
||||
template <class Tcls_>
|
||||
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls* pT)
|
||||
FORCEINLINE void CCountedPtr<Tcls_>::Assign(Tcls *pT)
|
||||
{
|
||||
// if they are the same, we do nothing
|
||||
if (pT != m_pT) {
|
||||
if (pT) pT->AddRef(); // AddRef new pointer if any
|
||||
Tcls* pTold = m_pT; // save original ptr
|
||||
Tcls *pTold = m_pT; // save original ptr
|
||||
m_pT = pT; // update m_pT to new value
|
||||
if (pTold) pTold->Release(); // release old ptr if any
|
||||
}
|
||||
|
@@ -11,18 +11,18 @@ struct CCrc32
|
||||
static uint32 Calc(const void *pBuffer, int nCount)
|
||||
{
|
||||
uint32 crc = 0xffffffff;
|
||||
const uint32* pTable = CrcTable();
|
||||
const uint32 *pTable = CrcTable();
|
||||
|
||||
uint8* begin = (uint8*)pBuffer;
|
||||
uint8* end = begin + nCount;
|
||||
for(uint8* cur = begin; cur < end; cur++)
|
||||
uint8 *begin = (uint8*)pBuffer;
|
||||
uint8 *end = begin + nCount;
|
||||
for(uint8 *cur = begin; cur < end; cur++)
|
||||
crc = (crc >> 8) ^ pTable[cur[0] ^ (uint8)(crc & 0xff)];
|
||||
crc ^= 0xffffffff;
|
||||
|
||||
return crc;
|
||||
}
|
||||
|
||||
static const uint32* CrcTable()
|
||||
static const uint32 *CrcTable()
|
||||
{
|
||||
static const uint32 Table[256] =
|
||||
{
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include "dbg_helpers.h"
|
||||
|
||||
/** Trackdir & TrackdirBits short names. */
|
||||
static const char* trackdir_names[] = {
|
||||
static const char *trackdir_names[] = {
|
||||
"NE", "SE", "UE", "LE", "LS", "RS", "rne", "rse",
|
||||
"SW", "NW", "UW", "LW", "LN", "RN", "rsw", "rnw",
|
||||
};
|
||||
@@ -34,7 +34,7 @@ CStrA ValueStr(TrackdirBits td_bits)
|
||||
|
||||
|
||||
/** DiagDirection short names. */
|
||||
static const char* diagdir_names[] = {
|
||||
static const char *diagdir_names[] = {
|
||||
"NE", "SE", "SW", "NW",
|
||||
};
|
||||
|
||||
@@ -48,7 +48,7 @@ CStrA ValueStr(DiagDirection dd)
|
||||
|
||||
|
||||
/** SignalType short names. */
|
||||
static const char* signal_type_names[] = {
|
||||
static const char *signal_type_names[] = {
|
||||
"NORMAL", "ENTRY", "EXIT", "COMBO", "PBS", "NOENTRY",
|
||||
};
|
||||
|
||||
|
@@ -59,7 +59,7 @@ inline typename ArrayT<T>::item_t ItemAtT(E idx, T &t, typename ArrayT<T>::item_
|
||||
* or t_unk when index is out of bounds.
|
||||
*/
|
||||
template <typename E, typename T>
|
||||
inline CStrA ComposeNameT(E value, T &t, const char* t_unk, E val_inv, const char* name_inv)
|
||||
inline CStrA ComposeNameT(E value, T &t, const char *t_unk, E val_inv, const char *name_inv)
|
||||
{
|
||||
CStrA out;
|
||||
if (value == val_inv) {
|
||||
@@ -123,7 +123,7 @@ struct DumpTarget {
|
||||
|
||||
static size_t& LastTypeId();
|
||||
CStrA GetCurrentStructName();
|
||||
bool FindKnownName(size_t type_id, const void* ptr, CStrA &name);
|
||||
bool FindKnownName(size_t type_id, const void *ptr, CStrA &name);
|
||||
|
||||
void WriteIndent();
|
||||
|
||||
|
@@ -63,7 +63,7 @@ struct CFixedSizeArrayT {
|
||||
FORCEINLINE void Clear()
|
||||
{
|
||||
// walk through all allocated items backward and destroy them
|
||||
for (Titem* pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) {
|
||||
for (Titem *pItem = &m_items[Size() - 1]; pItem >= m_items; pItem--) {
|
||||
pItem->~Titem_();
|
||||
}
|
||||
// number of items become zero
|
||||
|
@@ -10,7 +10,7 @@ struct CHashTableSlotT
|
||||
{
|
||||
typedef typename Titem_::Key Key; // make Titem_::Key a property of HashTable
|
||||
|
||||
Titem_* m_pFirst;
|
||||
Titem_ *m_pFirst;
|
||||
|
||||
CHashTableSlotT() : m_pFirst(NULL) {}
|
||||
|
||||
@@ -18,9 +18,9 @@ struct CHashTableSlotT
|
||||
FORCEINLINE void Clear() {m_pFirst = NULL;}
|
||||
|
||||
/** hash table slot helper - linear search for item with given key through the given blob - const version */
|
||||
FORCEINLINE const Titem_* Find(const Key& key) const
|
||||
FORCEINLINE const Titem_ *Find(const Key& key) const
|
||||
{
|
||||
for (const Titem_* pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
for (const Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
if (pItem->GetKey() == key) {
|
||||
// we have found the item, return it
|
||||
return pItem;
|
||||
@@ -30,9 +30,9 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - linear search for item with given key through the given blob - non-const version */
|
||||
FORCEINLINE Titem_* Find(const Key& key)
|
||||
FORCEINLINE Titem_ *Find(const Key& key)
|
||||
{
|
||||
for (Titem_* pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
for (Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
if (pItem->GetKey() == key) {
|
||||
// we have found the item, return it
|
||||
return pItem;
|
||||
@@ -57,12 +57,12 @@ struct CHashTableSlotT
|
||||
item_to_remove.SetHashNext(NULL);
|
||||
return true;
|
||||
}
|
||||
Titem_* pItem = m_pFirst;
|
||||
Titem_ *pItem = m_pFirst;
|
||||
while (true) {
|
||||
if (pItem == NULL) {
|
||||
return false;
|
||||
}
|
||||
Titem_* pNextItem = pItem->GetHashNext();
|
||||
Titem_ *pNextItem = pItem->GetHashNext();
|
||||
if (pNextItem == &item_to_remove) break;
|
||||
pItem = pNextItem;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - remove and return item from a slot */
|
||||
FORCEINLINE Titem_* Detach(const Key& key)
|
||||
FORCEINLINE Titem_ *Detach(const Key& key)
|
||||
{
|
||||
// do we have any items?
|
||||
if (m_pFirst == NULL) {
|
||||
@@ -86,8 +86,8 @@ struct CHashTableSlotT
|
||||
return &ret_item;
|
||||
}
|
||||
// find it in the following items
|
||||
Titem_* pPrev = m_pFirst;
|
||||
for (Titem_* pItem = m_pFirst->GetHashNext(); pItem != NULL; pPrev = pItem, pItem = pItem->GetHashNext()) {
|
||||
Titem_ *pPrev = m_pFirst;
|
||||
for (Titem_ *pItem = m_pFirst->GetHashNext(); pItem != NULL; pPrev = pItem, pItem = pItem->GetHashNext()) {
|
||||
if (pItem->GetKey() == key) {
|
||||
// we have found the item, unlink and return it
|
||||
pPrev->SetHashNext(pItem->GetHashNext());
|
||||
@@ -133,8 +133,8 @@ protected:
|
||||
* Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
|
||||
typedef CHashTableSlotT<Titem_> Slot;
|
||||
|
||||
Slot* m_slots; // here we store our data (array of blobs)
|
||||
int m_num_items; // item counter
|
||||
Slot *m_slots; // here we store our data (array of blobs)
|
||||
int m_num_items; // item counter
|
||||
|
||||
public:
|
||||
// default constructor
|
||||
@@ -171,29 +171,29 @@ public:
|
||||
FORCEINLINE void Clear() const {for (int i = 0; i < Tcapacity; i++) m_slots[i].Clear();}
|
||||
|
||||
/** const item search */
|
||||
const Titem_* Find(const Tkey& key) const
|
||||
const Titem_ *Find(const Tkey& key) const
|
||||
{
|
||||
int hash = CalcHash(key);
|
||||
const Slot& slot = m_slots[hash];
|
||||
const Titem_* item = slot.Find(key);
|
||||
const Titem_ *item = slot.Find(key);
|
||||
return item;
|
||||
}
|
||||
|
||||
/** non-const item search */
|
||||
Titem_* Find(const Tkey& key)
|
||||
Titem_ *Find(const Tkey& key)
|
||||
{
|
||||
int hash = CalcHash(key);
|
||||
Slot& slot = m_slots[hash];
|
||||
Titem_* item = slot.Find(key);
|
||||
Titem_ *item = slot.Find(key);
|
||||
return item;
|
||||
}
|
||||
|
||||
/** non-const item search & optional removal (if found) */
|
||||
Titem_* TryPop(const Tkey& key)
|
||||
Titem_ *TryPop(const Tkey& key)
|
||||
{
|
||||
int hash = CalcHash(key);
|
||||
Slot& slot = m_slots[hash];
|
||||
Titem_* item = slot.Detach(key);
|
||||
Titem_ *item = slot.Detach(key);
|
||||
if (item != NULL) {
|
||||
m_num_items--;
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
/** non-const item search & removal */
|
||||
Titem_& Pop(const Tkey& key)
|
||||
{
|
||||
Titem_* item = TryPop(key);
|
||||
Titem_ *item = TryPop(key);
|
||||
assert(item != NULL);
|
||||
return *item;
|
||||
}
|
||||
|
@@ -19,19 +19,19 @@ struct CStrT : public CBlobT<Tchar>
|
||||
typedef typename base::OnTransfer OnTransfer; ///< temporary 'transfer ownership' object type
|
||||
|
||||
/** Construction from C zero ended string. */
|
||||
FORCEINLINE CStrT(const Tchar* str = NULL)
|
||||
FORCEINLINE CStrT(const Tchar *str = NULL)
|
||||
{
|
||||
AppendStr(str);
|
||||
}
|
||||
|
||||
/** Construction from C string and given number of characters. */
|
||||
FORCEINLINE CStrT(const Tchar* str, bsize_t num_chars) : base(str, num_chars)
|
||||
FORCEINLINE CStrT(const Tchar *str, bsize_t num_chars) : base(str, num_chars)
|
||||
{
|
||||
base::FixTail();
|
||||
}
|
||||
|
||||
/** Construction from C string determined by 'begin' and 'end' pointers. */
|
||||
FORCEINLINE CStrT(const Tchar* str, const Tchar* end)
|
||||
FORCEINLINE CStrT(const Tchar *str, const Tchar *end)
|
||||
: base(str, end - str)
|
||||
{
|
||||
base::FixTail();
|
||||
@@ -58,15 +58,15 @@ struct CStrT : public CBlobT<Tchar>
|
||||
}
|
||||
|
||||
/** Grow the actual buffer and fix the trailing zero at the end. */
|
||||
FORCEINLINE Tchar* GrowSizeNC(bsize_t count)
|
||||
FORCEINLINE Tchar *GrowSizeNC(bsize_t count)
|
||||
{
|
||||
Tchar* ret = base::GrowSizeNC(count);
|
||||
Tchar *ret = base::GrowSizeNC(count);
|
||||
base::FixTail();
|
||||
return ret;
|
||||
}
|
||||
|
||||
/** Append zero-ended C string. */
|
||||
FORCEINLINE void AppendStr(const Tchar* str)
|
||||
FORCEINLINE void AppendStr(const Tchar *str)
|
||||
{
|
||||
if (str != NULL && str[0] != '\0') {
|
||||
base::Append(str, (bsize_t)Api::StrLen(str));
|
||||
@@ -84,7 +84,7 @@ struct CStrT : public CBlobT<Tchar>
|
||||
}
|
||||
|
||||
/** Assignment from C string. */
|
||||
FORCEINLINE CStrT& operator = (const Tchar* src)
|
||||
FORCEINLINE CStrT& operator = (const Tchar *src)
|
||||
{
|
||||
base::Clear();
|
||||
AppendStr(src);
|
||||
|
Reference in New Issue
Block a user