From db04dd427d51aca647d68eb5a688273ee16f2fea Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 3 May 2008 23:02:05 +0000 Subject: Formatting. svn-id: r31852 --- common/array.h | 18 +++++++------- common/func.h | 8 +++---- common/hashmap.h | 66 ++++++++++++++++++++++++++-------------------------- common/list.h | 20 ++++++++-------- common/noncopyable.h | 2 +- common/singleton.h | 12 +++++----- common/stack.h | 18 +++++++------- 7 files changed, 72 insertions(+), 72 deletions(-) diff --git a/common/array.h b/common/array.h index ff98ec4307..24a07b49bf 100644 --- a/common/array.h +++ b/common/array.h @@ -30,7 +30,7 @@ namespace Common { -template +template class Array { protected: uint _capacity; @@ -45,7 +45,7 @@ public: public: Array() : _capacity(0), _size(0), _data(0) {} - Array(const Array& array) : _capacity(0), _size(0), _data(0) { + Array(const Array &array) : _capacity(0), _size(0), _data(0) { _size = array._size; _capacity = _size + 32; _data = new T[_capacity]; @@ -53,21 +53,21 @@ public: } ~Array() { - delete [] _data; + delete[] _data; } - void push_back(const T& element) { + void push_back(const T &element) { ensureCapacity(_size + 1); _data[_size++] = element; } - void push_back(const Array& array) { + void push_back(const Array &array) { ensureCapacity(_size + array._size); copy(array._data, array._data + array._size, _data + _size); _size += array._size; } - void insert_at(int idx, const T& element) { + void insert_at(int idx, const T &element) { assert(idx >= 0 && (uint)idx <= _size); ensureCapacity(_size + 1); copy_backward(_data + idx, _data + _size, _data + _size + 1); @@ -85,17 +85,17 @@ public: // TODO: insert, remove, ... - T& operator [](int idx) { + T& operator[](int idx) { assert(idx >= 0 && (uint)idx < _size); return _data[idx]; } - const T& operator [](int idx) const { + const T& operator[](int idx) const { assert(idx >= 0 && (uint)idx < _size); return _data[idx]; } - Array& operator =(const Array& array) { + Array& operator=(const Array &array) { if (this == &array) return *this; diff --git a/common/func.h b/common/func.h index fa8f0d2151..95df96123a 100644 --- a/common/func.h +++ b/common/func.h @@ -279,13 +279,13 @@ private: * Base template for hash functor objects, used by HashMap. * This needs to be specialized for every type that you need to hash. */ -template struct Hash; +template struct Hash; #define GENERATE_TRIVIAL_HASH_FUNCTOR(T) \ - template <> struct Hash : public UnaryFunction { \ - uint operator()(T val) const { return (uint)val; } \ - } + template<> struct Hash : public UnaryFunction { \ + uint operator()(T val) const { return (uint)val; } \ + } GENERATE_TRIVIAL_HASH_FUNCTOR(bool); GENERATE_TRIVIAL_HASH_FUNCTOR(char); diff --git a/common/hashmap.h b/common/hashmap.h index fb1de38fd1..81a4b0d17e 100644 --- a/common/hashmap.h +++ b/common/hashmap.h @@ -94,7 +94,7 @@ uint nextTableSize(uint x); * triggered instead. Hence if you are not sure whether a key is contained in * the map, use contains() first to check for its presence. */ -template , class EqualFunc = EqualTo > +template, class EqualFunc = EqualTo > class HashMap { private: #if defined (PALMOS_MODE) @@ -113,17 +113,17 @@ public: #ifdef USE_HASHMAP_MEMORY_POOL MemoryPool _nodePool; - Node *allocNode(const Key& key) { + Node *allocNode(const Key &key) { void* mem = _nodePool.malloc(); return new (mem) Node(key); } - void freeNode(Node* node) { + void freeNode(Node *node) { node->~Node(); _nodePool.free(node); } #else - Node* allocNode(const Key& key) { + Node* allocNode(const Key &key) { return new Node(key); } @@ -145,7 +145,7 @@ public: mutable int _collisions, _lookups; #endif - void assign(const HM_t& map); + void assign(const HM_t &map); int lookup(const Key &key) const; int lookupAndCreateIfMissing(const Key &key); void expand_array(uint newsize); @@ -181,13 +181,13 @@ public: template IteratorImpl(const IteratorImpl &c) : _idx(c._idx), _hashmap(c._hashmap) {} - NodeType &operator *() const { return *deref(); } + NodeType &operator*() const { return *deref(); } NodeType *operator->() const { return deref(); } - bool operator ==(const IteratorImpl &iter) const { return _idx == iter._idx && _hashmap == iter._hashmap; } - bool operator !=(const IteratorImpl &iter) const { return !(*this == iter); } + bool operator==(const IteratorImpl &iter) const { return _idx == iter._idx && _hashmap == iter._hashmap; } + bool operator!=(const IteratorImpl &iter) const { return !(*this == iter); } - IteratorImpl &operator ++() { + IteratorImpl &operator++() { assert(_hashmap); do { _idx++; @@ -198,7 +198,7 @@ public: return *this; } - IteratorImpl operator ++(int) { + IteratorImpl operator++(int) { IteratorImpl old = *this; operator ++(); return old; @@ -210,10 +210,10 @@ public: typedef IteratorImpl const_iterator; HashMap(); - HashMap(const HM_t& map); + HashMap(const HM_t &map); ~HashMap(); - HM_t &operator =(const HM_t &map) { + HM_t &operator=(const HM_t &map) { if (this == &map) return *this; @@ -227,8 +227,8 @@ public: bool contains(const Key &key) const; - Val &operator [](const Key &key); - const Val &operator [](const Key &key) const; + Val &operator[](const Key &key); + const Val &operator[](const Key &key) const; Val &getVal(const Key &key); const Val &getVal(const Key &key) const; @@ -291,7 +291,7 @@ public: /** * Base constructor, creates an empty hashmap. */ -template +template HashMap::HashMap() : #ifdef USE_HASHMAP_MEMORY_POOL _nodePool(sizeof(Node)), @@ -315,8 +315,8 @@ HashMap::HashMap() : * We must provide a custom copy constructor as we use pointers * to heap buffers for the internal storage. */ -template -HashMap::HashMap(const HM_t& map) : +template +HashMap::HashMap(const HM_t &map) : #ifdef USE_HASHMAP_MEMORY_POOL _nodePool(sizeof(Node)), #endif @@ -327,7 +327,7 @@ HashMap::HashMap(const HM_t& map) : /** * Destructor, frees all used memory. */ -template +template HashMap::~HashMap() { for (uint ctr = 0; ctr < _arrsize; ++ctr) if (_arr[ctr] != NULL) @@ -343,8 +343,8 @@ HashMap::~HashMap() { * @note We do *not* deallocate the previous storage here -- the caller is * responsible for doing that! */ -template -void HashMap::assign(const HM_t& map) { +template +void HashMap::assign(const HM_t &map) { _arrsize = map._arrsize; _arr = new Node *[_arrsize]; assert(_arr != NULL); @@ -364,7 +364,7 @@ void HashMap::assign(const HM_t& map) { } -template +template void HashMap::clear(bool shrinkArray) { for (uint ctr = 0; ctr < _arrsize; ++ctr) { if (_arr[ctr] != NULL) { @@ -385,7 +385,7 @@ void HashMap::clear(bool shrinkArray) { _nele = 0; } -template +template void HashMap::expand_array(uint newsize) { assert(newsize > _arrsize); uint ctr, dex; @@ -428,7 +428,7 @@ void HashMap::expand_array(uint newsize) { return; } -template +template int HashMap::lookup(const Key &key) const { uint ctr = _hash(key) % _arrsize; @@ -450,7 +450,7 @@ int HashMap::lookup(const Key &key) const { return ctr; } -template +template int HashMap::lookupAndCreateIfMissing(const Key &key) { uint ctr = lookup(key); @@ -469,30 +469,30 @@ int HashMap::lookupAndCreateIfMissing(const Key & } -template +template bool HashMap::contains(const Key &key) const { uint ctr = lookup(key); return (_arr[ctr] != NULL); } -template -Val &HashMap::operator [](const Key &key) { +template +Val &HashMap::operator[](const Key &key) { return getVal(key); } -template -const Val &HashMap::operator [](const Key &key) const { +template +const Val &HashMap::operator[](const Key &key) const { return getVal(key); } -template +template Val &HashMap::getVal(const Key &key) { uint ctr = lookupAndCreateIfMissing(key); assert(_arr[ctr] != NULL); return _arr[ctr]->_value; } -template +template const Val &HashMap::getVal(const Key &key) const { uint ctr = lookup(key); if (_arr[ctr] != NULL) @@ -501,14 +501,14 @@ const Val &HashMap::getVal(const Key &key) const return _defaultVal; } -template +template void HashMap::setVal(const Key &key, const Val &val) { uint ctr = lookupAndCreateIfMissing(key); assert(_arr[ctr] != NULL); _arr[ctr]->_value = val; } -template +template void HashMap::erase(const Key &key) { // This is based on code in the Wikipedia article on Hash tables. uint i = lookup(key); diff --git a/common/list.h b/common/list.h index fb093804ce..c4e7b47644 100644 --- a/common/list.h +++ b/common/list.h @@ -33,7 +33,7 @@ namespace Common { * Simple double linked list, modeled after the list template of the standard * C++ library. */ -template +template class List { protected: #if defined (_WIN32_WCE) || defined (_MSC_VER) @@ -52,7 +52,7 @@ public: Node(const t_T2 &x) : _data(x) {} }; - template + template class Iterator { template friend class Iterator; friend class List; @@ -70,7 +70,7 @@ public: Iterator(const Iterator &c) : _node(c._node) {} template - Iterator &operator =(const Iterator &c) { + Iterator &operator=(const Iterator &c) { _node = c._node; return *this; } @@ -104,7 +104,7 @@ public: #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 95) return static_cast::Node *>(_node)->_data; #else - return static_cast*>(_node)->_data; + return static_cast *>(_node)->_data; #endif } t_T2 *operator->() const { @@ -135,7 +135,7 @@ public: _anchor._prev = &_anchor; _anchor._next = &_anchor; } - List(const List& list) { + List(const List &list) { _anchor._prev = &_anchor; _anchor._next = &_anchor; @@ -146,15 +146,15 @@ public: clear(); } - void push_front(const t_T& element) { + void push_front(const t_T &element) { insert(begin(), element); } - void push_back(const t_T& element) { + void push_back(const t_T &element) { insert(end(), element); } - void insert(iterator pos, const t_T& element) { + void insert(iterator pos, const t_T &element) { NodeBase *newNode = new Node(element); newNode->_next = pos._node; @@ -163,7 +163,7 @@ public: newNode->_next->_prev = newNode; } - template + template void insert(iterator pos, iterator2 first, iterator2 last) { for (; first != last; ++first) insert(pos, *first); @@ -210,7 +210,7 @@ public: } - List& operator =(const List& list) { + List &operator=(const List &list) { if (this != &list) { iterator i; const_iterator j; diff --git a/common/noncopyable.h b/common/noncopyable.h index e0af397546..f639d9abf7 100644 --- a/common/noncopyable.h +++ b/common/noncopyable.h @@ -38,7 +38,7 @@ public: private: // Prevent copying instances by accident NonCopyable(const NonCopyable&); - NonCopyable& operator= (const NonCopyable&); + NonCopyable& operator=(const NonCopyable&); }; } // End of namespace Common diff --git a/common/singleton.h b/common/singleton.h index be9f5d6dba..1a7b339bf6 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -33,13 +33,13 @@ namespace Common { /** * Generic template base class for implementing the singleton design pattern. */ -template +template class Singleton : NonCopyable { private: - Singleton(const Singleton&); - Singleton& operator= (const Singleton&); + Singleton(const Singleton &); + Singleton &operator=(const Singleton &); - static T* _singleton; + static T *_singleton; /** * The default object factory used by the template class Singleton. @@ -53,7 +53,7 @@ private: //FIXME evc4 and msvc7 doesn't like it as private member public: #endif - static T* makeInstance() { + static T *makeInstance() { return new T(); } @@ -91,7 +91,7 @@ protected: typedef T SingletonBaseType; }; -#define DECLARE_SINGLETON(T) template<> T* Common::Singleton::_singleton=0 +#define DECLARE_SINGLETON(T) template<> T *Common::Singleton::_singleton = 0 } // End of namespace Common diff --git a/common/stack.h b/common/stack.h index 1d38c7d2ac..876efacc3f 100644 --- a/common/stack.h +++ b/common/stack.h @@ -33,7 +33,7 @@ namespace Common { /** * Extremly simple fixed size stack class. */ -template +template class FixedStack { protected: T _stack[MAX_SIZE]; @@ -47,15 +47,15 @@ public: void clear() { _size = 0; } - void push(const T& x) { + void push(const T &x) { assert(_size < MAX_SIZE); _stack[_size++] = x; } - const T& top() const { + const T &top() const { assert(_size > 0); return _stack[_size - 1]; } - T& top() { + T &top() { assert(_size > 0); return _stack[_size - 1]; } @@ -67,11 +67,11 @@ public: int size() const { return _size; } - T& operator [](int i) { + T &operator[](int i) { assert(0 <= i && i < MAX_SIZE); return _stack[i]; } - const T& operator [](int i) const { + const T &operator[](int i) const { assert(0 <= i && i < MAX_SIZE); return _stack[i]; } @@ -81,7 +81,7 @@ public: /** * Variable size stack class, implemented using our Array class. */ -template +template class Stack { protected: Array _stack; @@ -95,7 +95,7 @@ public: void clear() { _stack.clear(); } - void push(const T& x) { + void push(const T &x) { _stack.push_back(x); } T top() const { @@ -110,7 +110,7 @@ public: int size() const { return _stack.size(); } - T operator [](int i) { + T operator[](int i) { return _stack[i]; } }; -- cgit v1.2.3