(svn r27362) -Codechange: Codestyle fixes for reference var declarations, static cast type, operator methods.
This commit is contained in:
@@ -34,7 +34,7 @@ protected:
|
||||
{
|
||||
uint super_size = data.Length();
|
||||
if (super_size > 0) {
|
||||
SubArray& s = data[super_size - 1];
|
||||
SubArray &s = data[super_size - 1];
|
||||
if (!s.IsFull()) return s;
|
||||
}
|
||||
return *data.AppendC();
|
||||
@@ -62,17 +62,17 @@ public:
|
||||
/** allocate and construct new item */
|
||||
inline T *AppendC() { return FirstFreeSubArray().AppendC(); }
|
||||
/** indexed access (non-const) */
|
||||
inline T& operator [] (uint index)
|
||||
inline T& operator[](uint index)
|
||||
{
|
||||
const SubArray& s = data[index / B];
|
||||
T& item = s[index % B];
|
||||
const SubArray &s = data[index / B];
|
||||
T &item = s[index % B];
|
||||
return item;
|
||||
}
|
||||
/** indexed access (const) */
|
||||
inline const T& operator [] (uint index) const
|
||||
inline const T& operator[](uint index) const
|
||||
{
|
||||
const SubArray& s = data[index / B];
|
||||
const T& item = s[index % B];
|
||||
const SubArray &s = data[index / B];
|
||||
const T &item = s[index % B];
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
dmp.WriteLine("num_items = %d", num_items);
|
||||
CStrA name;
|
||||
for (uint i = 0; i < num_items; i++) {
|
||||
const T& item = (*this)[i];
|
||||
const T &item = (*this)[i];
|
||||
name.Format("item[%d]", i);
|
||||
dmp.WriteStructT(name.Data(), &item);
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ public:
|
||||
inline CCountedPtr(Tcls *pObj = NULL) : m_pT(pObj) {AddRef();}
|
||||
|
||||
/** copy constructor (invoked also when initializing from another smart ptr) */
|
||||
inline CCountedPtr(const CCountedPtr& src) : m_pT(src.m_pT) {AddRef();}
|
||||
inline CCountedPtr(const CCountedPtr &src) : m_pT(src.m_pT) {AddRef();}
|
||||
|
||||
/** destructor releasing the reference */
|
||||
inline ~CCountedPtr() {Release();}
|
||||
@@ -52,10 +52,10 @@ public:
|
||||
inline void Release() {if (m_pT != NULL) {Tcls *pT = m_pT; m_pT = NULL; pT->Release();}}
|
||||
|
||||
/** dereference of smart pointer - const way */
|
||||
inline const Tcls *operator -> () const {assert(m_pT != NULL); return m_pT;}
|
||||
inline const Tcls *operator->() const {assert(m_pT != NULL); return m_pT;}
|
||||
|
||||
/** dereference of smart pointer - non const way */
|
||||
inline Tcls *operator -> () {assert(m_pT != NULL); return m_pT;}
|
||||
inline Tcls *operator->() {assert(m_pT != NULL); return m_pT;}
|
||||
|
||||
/** raw pointer casting operator - const way */
|
||||
inline operator const Tcls*() const {assert(m_pT == NULL); return m_pT;}
|
||||
@@ -64,13 +64,13 @@ public:
|
||||
inline operator Tcls*() {return m_pT;}
|
||||
|
||||
/** operator & to support output arguments */
|
||||
inline Tcls** operator &() {assert(m_pT == NULL); return &m_pT;}
|
||||
inline Tcls** operator&() {assert(m_pT == NULL); return &m_pT;}
|
||||
|
||||
/** assignment operator from raw ptr */
|
||||
inline CCountedPtr& operator = (Tcls *pT) {Assign(pT); return *this;}
|
||||
inline CCountedPtr& operator=(Tcls *pT) {Assign(pT); return *this;}
|
||||
|
||||
/** assignment operator from another smart ptr */
|
||||
inline CCountedPtr& operator = (const CCountedPtr& src) {Assign(src.m_pT); return *this;}
|
||||
inline CCountedPtr& operator=(const CCountedPtr &src) {Assign(src.m_pT); return *this;}
|
||||
|
||||
/** assignment operator helper */
|
||||
inline void Assign(Tcls *pT);
|
||||
@@ -79,10 +79,10 @@ public:
|
||||
inline bool IsNull() const {return m_pT == NULL;}
|
||||
|
||||
/** another way how to test for NULL value */
|
||||
//inline bool operator == (const CCountedPtr& sp) const {return m_pT == sp.m_pT;}
|
||||
//inline bool operator == (const CCountedPtr &sp) const {return m_pT == sp.m_pT;}
|
||||
|
||||
/** yet another way how to test for NULL value */
|
||||
//inline bool operator != (const CCountedPtr& sp) const {return m_pT != sp.m_pT;}
|
||||
//inline bool operator != (const CCountedPtr &sp) const {return m_pT != sp.m_pT;}
|
||||
|
||||
/** assign pointer w/o incrementing ref count */
|
||||
inline void Attach(Tcls *pT) {Release(); m_pT = pT;}
|
||||
|
@@ -111,7 +111,7 @@ struct DumpTarget {
|
||||
m_ptr = src.m_ptr;
|
||||
}
|
||||
|
||||
bool operator < (const KnownStructKey &other) const
|
||||
bool operator<(const KnownStructKey &other) const
|
||||
{
|
||||
if ((size_t)m_ptr < (size_t)other.m_ptr) return true;
|
||||
if ((size_t)m_ptr > (size_t)other.m_ptr) return false;
|
||||
|
@@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
/** Copy constructor. Preallocate space for items and header, then initialize header. */
|
||||
FixedSizeArray(const FixedSizeArray<T, C>& src)
|
||||
FixedSizeArray(const FixedSizeArray<T, C> &src)
|
||||
{
|
||||
/* share block (header + items) with the source array */
|
||||
data = src.data;
|
||||
@@ -106,9 +106,9 @@ public:
|
||||
/** add and construct item using default constructor */
|
||||
inline T *AppendC() { T *item = Append(); new(item)T; return item; }
|
||||
/** return item by index (non-const version) */
|
||||
inline T& operator [] (uint index) { assert(index < Length()); return data[index]; }
|
||||
inline T& operator[](uint index) { assert(index < Length()); return data[index]; }
|
||||
/** return item by index (const version) */
|
||||
inline const T& operator [] (uint index) const { assert(index < Length()); return data[index]; }
|
||||
inline const T& operator[](uint index) const { assert(index < Length()); return data[index]; }
|
||||
};
|
||||
|
||||
#endif /* FIXEDSIZEARRAY_HPP */
|
||||
|
@@ -27,7 +27,7 @@ struct CHashTableSlotT
|
||||
inline void Clear() {m_pFirst = NULL;}
|
||||
|
||||
/** hash table slot helper - linear search for item with given key through the given blob - const version */
|
||||
inline const Titem_ *Find(const Key& key) const
|
||||
inline const Titem_ *Find(const Key &key) const
|
||||
{
|
||||
for (const Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
if (pItem->GetKey() == key) {
|
||||
@@ -39,7 +39,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - linear search for item with given key through the given blob - non-const version */
|
||||
inline Titem_ *Find(const Key& key)
|
||||
inline Titem_ *Find(const Key &key)
|
||||
{
|
||||
for (Titem_ *pItem = m_pFirst; pItem != NULL; pItem = pItem->GetHashNext()) {
|
||||
if (pItem->GetKey() == key) {
|
||||
@@ -51,7 +51,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - add new item to the slot */
|
||||
inline void Attach(Titem_& new_item)
|
||||
inline void Attach(Titem_ &new_item)
|
||||
{
|
||||
assert(new_item.GetHashNext() == NULL);
|
||||
new_item.SetHashNext(m_pFirst);
|
||||
@@ -59,7 +59,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - remove item from a slot */
|
||||
inline bool Detach(Titem_& item_to_remove)
|
||||
inline bool Detach(Titem_ &item_to_remove)
|
||||
{
|
||||
if (m_pFirst == &item_to_remove) {
|
||||
m_pFirst = item_to_remove.GetHashNext();
|
||||
@@ -81,7 +81,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
|
||||
/** hash table slot helper - remove and return item from a slot */
|
||||
inline Titem_ *Detach(const Key& key)
|
||||
inline Titem_ *Detach(const Key &key)
|
||||
{
|
||||
/* do we have any items? */
|
||||
if (m_pFirst == NULL) {
|
||||
@@ -89,7 +89,7 @@ struct CHashTableSlotT
|
||||
}
|
||||
/* is it our first item? */
|
||||
if (m_pFirst->GetKey() == key) {
|
||||
Titem_& ret_item = *m_pFirst;
|
||||
Titem_ &ret_item = *m_pFirst;
|
||||
m_pFirst = m_pFirst->GetHashNext();
|
||||
ret_item.SetHashNext(NULL);
|
||||
return &ret_item;
|
||||
@@ -128,7 +128,7 @@ struct CHashTableSlotT
|
||||
* - public method that calculates key's hash:
|
||||
* int CalcHash() const;
|
||||
* - public 'equality' operator to compare the key with another one
|
||||
* bool operator == (const Key& other) const;
|
||||
* bool operator==(const Key &other) const;
|
||||
*/
|
||||
template <class Titem_, int Thash_bits_>
|
||||
class CHashTableT {
|
||||
@@ -156,7 +156,7 @@ public:
|
||||
|
||||
protected:
|
||||
/** static helper - return hash for the given key modulo number of slots */
|
||||
inline static int CalcHash(const Tkey& key)
|
||||
inline static int CalcHash(const Tkey &key)
|
||||
{
|
||||
int32 hash = key.CalcHash();
|
||||
if ((8 * Thash_bits) < 32) hash ^= hash >> (min(8 * Thash_bits, 31));
|
||||
@@ -168,7 +168,7 @@ protected:
|
||||
}
|
||||
|
||||
/** static helper - return hash for the given item modulo number of slots */
|
||||
inline static int CalcHash(const Titem_& item) {return CalcHash(item.GetKey());}
|
||||
inline static int CalcHash(const Titem_ &item) {return CalcHash(item.GetKey());}
|
||||
|
||||
public:
|
||||
/** item count */
|
||||
@@ -178,28 +178,28 @@ public:
|
||||
inline void Clear() {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 Slot &slot = m_slots[hash];
|
||||
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];
|
||||
Slot &slot = m_slots[hash];
|
||||
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];
|
||||
Slot &slot = m_slots[hash];
|
||||
Titem_ *item = slot.Detach(key);
|
||||
if (item != NULL) {
|
||||
m_num_items--;
|
||||
@@ -208,7 +208,7 @@ public:
|
||||
}
|
||||
|
||||
/** non-const item search & removal */
|
||||
Titem_& Pop(const Tkey& key)
|
||||
Titem_& Pop(const Tkey &key)
|
||||
{
|
||||
Titem_ *item = TryPop(key);
|
||||
assert(item != NULL);
|
||||
@@ -216,11 +216,11 @@ public:
|
||||
}
|
||||
|
||||
/** non-const item search & optional removal (if found) */
|
||||
bool TryPop(Titem_& item)
|
||||
bool TryPop(Titem_ &item)
|
||||
{
|
||||
const Tkey& key = item.GetKey();
|
||||
const Tkey &key = item.GetKey();
|
||||
int hash = CalcHash(key);
|
||||
Slot& slot = m_slots[hash];
|
||||
Slot &slot = m_slots[hash];
|
||||
bool ret = slot.Detach(item);
|
||||
if (ret) {
|
||||
m_num_items--;
|
||||
@@ -229,17 +229,17 @@ public:
|
||||
}
|
||||
|
||||
/** non-const item search & removal */
|
||||
void Pop(Titem_& item)
|
||||
void Pop(Titem_ &item)
|
||||
{
|
||||
bool ret = TryPop(item);
|
||||
assert(ret);
|
||||
}
|
||||
|
||||
/** add one item - copy it from the given item */
|
||||
void Push(Titem_& new_item)
|
||||
void Push(Titem_ &new_item)
|
||||
{
|
||||
int hash = CalcHash(new_item);
|
||||
Slot& slot = m_slots[hash];
|
||||
Slot &slot = m_slots[hash];
|
||||
assert(slot.Find(new_item.GetKey()) == NULL);
|
||||
slot.Attach(new_item);
|
||||
m_num_items++;
|
||||
|
@@ -35,7 +35,7 @@ struct CStrA : public CBlobT<char>
|
||||
}
|
||||
|
||||
/** Take over ownership constructor */
|
||||
inline CStrA(const OnTransfer& ot)
|
||||
inline CStrA(const OnTransfer &ot)
|
||||
: base(ot)
|
||||
{
|
||||
}
|
||||
@@ -67,7 +67,7 @@ struct CStrA : public CBlobT<char>
|
||||
}
|
||||
|
||||
/** Assignment from C string. */
|
||||
inline CStrA &operator = (const char *src)
|
||||
inline CStrA &operator=(const char *src)
|
||||
{
|
||||
base::Clear();
|
||||
AppendStr(src);
|
||||
@@ -75,7 +75,7 @@ struct CStrA : public CBlobT<char>
|
||||
}
|
||||
|
||||
/** Assignment from another CStrA. */
|
||||
inline CStrA &operator = (const CStrA &src)
|
||||
inline CStrA &operator=(const CStrA &src)
|
||||
{
|
||||
if (&src != this) {
|
||||
base::Clear();
|
||||
@@ -86,7 +86,7 @@ struct CStrA : public CBlobT<char>
|
||||
}
|
||||
|
||||
/** Lower-than operator (to support stl collections) */
|
||||
inline bool operator < (const CStrA &other) const
|
||||
inline bool operator<(const CStrA &other) const
|
||||
{
|
||||
return strcmp(base::Data(), other.Data()) < 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user