summaryrefslogtreecommitdiff
path: root/src/misc
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/array.hpp16
-rw-r--r--src/misc/countedptr.hpp16
-rw-r--r--src/misc/dbg_helpers.h2
-rw-r--r--src/misc/fixedsizearray.hpp6
-rw-r--r--src/misc/hashtable.hpp44
-rw-r--r--src/misc/str.hpp8
6 files changed, 46 insertions, 46 deletions
diff --git a/src/misc/array.hpp b/src/misc/array.hpp
index a3f243e10..9796f18ea 100644
--- a/src/misc/array.hpp
+++ b/src/misc/array.hpp
@@ -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);
}
diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp
index 5dfc9a74c..1a783cf3e 100644
--- a/src/misc/countedptr.hpp
+++ b/src/misc/countedptr.hpp
@@ -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;}
diff --git a/src/misc/dbg_helpers.h b/src/misc/dbg_helpers.h
index c83086f2a..acc1437d0 100644
--- a/src/misc/dbg_helpers.h
+++ b/src/misc/dbg_helpers.h
@@ -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;
diff --git a/src/misc/fixedsizearray.hpp b/src/misc/fixedsizearray.hpp
index 4216570b8..bf0f3acdd 100644
--- a/src/misc/fixedsizearray.hpp
+++ b/src/misc/fixedsizearray.hpp
@@ -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 */
diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp
index 60bdcec25..e754a7d7b 100644
--- a/src/misc/hashtable.hpp
+++ b/src/misc/hashtable.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++;
diff --git a/src/misc/str.hpp b/src/misc/str.hpp
index b982913fc..1d9802288 100644
--- a/src/misc/str.hpp
+++ b/src/misc/str.hpp
@@ -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;
}