aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-05-03 23:02:05 +0000
committerJohannes Schickel2008-05-03 23:02:05 +0000
commitdb04dd427d51aca647d68eb5a688273ee16f2fea (patch)
treea4a3453e2d7ce3fa5c522b7d72747878bcf813b1
parent06dea145404f4a636205d5e01b104cec7d156869 (diff)
downloadscummvm-rg350-db04dd427d51aca647d68eb5a688273ee16f2fea.tar.gz
scummvm-rg350-db04dd427d51aca647d68eb5a688273ee16f2fea.tar.bz2
scummvm-rg350-db04dd427d51aca647d68eb5a688273ee16f2fea.zip
Formatting.
svn-id: r31852
-rw-r--r--common/array.h18
-rw-r--r--common/func.h8
-rw-r--r--common/hashmap.h66
-rw-r--r--common/list.h20
-rw-r--r--common/noncopyable.h2
-rw-r--r--common/singleton.h12
-rw-r--r--common/stack.h18
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 <class T>
+template<class T>
class Array {
protected:
uint _capacity;
@@ -45,7 +45,7 @@ public:
public:
Array() : _capacity(0), _size(0), _data(0) {}
- Array(const Array<T>& array) : _capacity(0), _size(0), _data(0) {
+ Array(const Array<T> &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<T>& array) {
+ void push_back(const Array<T> &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<T>& operator =(const Array<T>& array) {
+ Array<T>& operator=(const Array<T> &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 <typename T> struct Hash;
+template<typename T> struct Hash;
#define GENERATE_TRIVIAL_HASH_FUNCTOR(T) \
- template <> struct Hash<T> : public UnaryFunction<T, uint> { \
- uint operator()(T val) const { return (uint)val; } \
- }
+ template<> struct Hash<T> : public UnaryFunction<T, uint> { \
+ 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 Key, class Val, class HashFunc = Hash<Key>, class EqualFunc = EqualTo<Key> >
+template<class Key, class Val, class HashFunc = Hash<Key>, class EqualFunc = EqualTo<Key> >
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<class T>
IteratorImpl(const IteratorImpl<T> &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 Node> 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 <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
HashMap<Key, Val, HashFunc, EqualFunc>::HashMap() :
#ifdef USE_HASHMAP_MEMORY_POOL
_nodePool(sizeof(Node)),
@@ -315,8 +315,8 @@ HashMap<Key, Val, HashFunc, EqualFunc>::HashMap() :
* We must provide a custom copy constructor as we use pointers
* to heap buffers for the internal storage.
*/
-template <class Key, class Val, class HashFunc, class EqualFunc>
-HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t& map) :
+template<class Key, class Val, class HashFunc, class EqualFunc>
+HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t &map) :
#ifdef USE_HASHMAP_MEMORY_POOL
_nodePool(sizeof(Node)),
#endif
@@ -327,7 +327,7 @@ HashMap<Key, Val, HashFunc, EqualFunc>::HashMap(const HM_t& map) :
/**
* Destructor, frees all used memory.
*/
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
HashMap<Key, Val, HashFunc, EqualFunc>::~HashMap() {
for (uint ctr = 0; ctr < _arrsize; ++ctr)
if (_arr[ctr] != NULL)
@@ -343,8 +343,8 @@ HashMap<Key, Val, HashFunc, EqualFunc>::~HashMap() {
* @note We do *not* deallocate the previous storage here -- the caller is
* responsible for doing that!
*/
-template <class Key, class Val, class HashFunc, class EqualFunc>
-void HashMap<Key, Val, HashFunc, EqualFunc>::assign(const HM_t& map) {
+template<class Key, class Val, class HashFunc, class EqualFunc>
+void HashMap<Key, Val, HashFunc, EqualFunc>::assign(const HM_t &map) {
_arrsize = map._arrsize;
_arr = new Node *[_arrsize];
assert(_arr != NULL);
@@ -364,7 +364,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::assign(const HM_t& map) {
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
void HashMap<Key, Val, HashFunc, EqualFunc>::clear(bool shrinkArray) {
for (uint ctr = 0; ctr < _arrsize; ++ctr) {
if (_arr[ctr] != NULL) {
@@ -385,7 +385,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::clear(bool shrinkArray) {
_nele = 0;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
void HashMap<Key, Val, HashFunc, EqualFunc>::expand_array(uint newsize) {
assert(newsize > _arrsize);
uint ctr, dex;
@@ -428,7 +428,7 @@ void HashMap<Key, Val, HashFunc, EqualFunc>::expand_array(uint newsize) {
return;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
int HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const {
uint ctr = _hash(key) % _arrsize;
@@ -450,7 +450,7 @@ int HashMap<Key, Val, HashFunc, EqualFunc>::lookup(const Key &key) const {
return ctr;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
int HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key &key) {
uint ctr = lookup(key);
@@ -469,30 +469,30 @@ int HashMap<Key, Val, HashFunc, EqualFunc>::lookupAndCreateIfMissing(const Key &
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
bool HashMap<Key, Val, HashFunc, EqualFunc>::contains(const Key &key) const {
uint ctr = lookup(key);
return (_arr[ctr] != NULL);
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
-Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator [](const Key &key) {
+template<class Key, class Val, class HashFunc, class EqualFunc>
+Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator[](const Key &key) {
return getVal(key);
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
-const Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator [](const Key &key) const {
+template<class Key, class Val, class HashFunc, class EqualFunc>
+const Val &HashMap<Key, Val, HashFunc, EqualFunc>::operator[](const Key &key) const {
return getVal(key);
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) {
uint ctr = lookupAndCreateIfMissing(key);
assert(_arr[ctr] != NULL);
return _arr[ctr]->_value;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) const {
uint ctr = lookup(key);
if (_arr[ctr] != NULL)
@@ -501,14 +501,14 @@ const Val &HashMap<Key, Val, HashFunc, EqualFunc>::getVal(const Key &key) const
return _defaultVal;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
void HashMap<Key, Val, HashFunc, EqualFunc>::setVal(const Key &key, const Val &val) {
uint ctr = lookupAndCreateIfMissing(key);
assert(_arr[ctr] != NULL);
_arr[ctr]->_value = val;
}
-template <class Key, class Val, class HashFunc, class EqualFunc>
+template<class Key, class Val, class HashFunc, class EqualFunc>
void HashMap<Key, Val, HashFunc, EqualFunc>::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 <class t_T>
+template<class t_T>
class List {
protected:
#if defined (_WIN32_WCE) || defined (_MSC_VER)
@@ -52,7 +52,7 @@ public:
Node(const t_T2 &x) : _data(x) {}
};
- template <class t_T2>
+ template<class t_T2>
class Iterator {
template<class T> friend class Iterator;
friend class List<t_T>;
@@ -70,7 +70,7 @@ public:
Iterator(const Iterator<T> &c) : _node(c._node) {}
template<class T>
- Iterator<t_T2> &operator =(const Iterator<T> &c) {
+ Iterator<t_T2> &operator=(const Iterator<T> &c) {
_node = c._node;
return *this;
}
@@ -104,7 +104,7 @@ public:
#if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 95)
return static_cast<List<t_T>::Node<t_T2> *>(_node)->_data;
#else
- return static_cast<Node<t_T2>*>(_node)->_data;
+ return static_cast<Node<t_T2> *>(_node)->_data;
#endif
}
t_T2 *operator->() const {
@@ -135,7 +135,7 @@ public:
_anchor._prev = &_anchor;
_anchor._next = &_anchor;
}
- List(const List<t_T>& list) {
+ List(const List<t_T> &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<t_T>(element);
newNode->_next = pos._node;
@@ -163,7 +163,7 @@ public:
newNode->_next->_prev = newNode;
}
- template <typename iterator2>
+ template<typename iterator2>
void insert(iterator pos, iterator2 first, iterator2 last) {
for (; first != last; ++first)
insert(pos, *first);
@@ -210,7 +210,7 @@ public:
}
- List<t_T>& operator =(const List<t_T>& list) {
+ List<t_T> &operator=(const List<t_T> &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 <class T>
+template<class T>
class Singleton : NonCopyable {
private:
- Singleton<T>(const Singleton<T>&);
- Singleton<T>& operator= (const Singleton<T>&);
+ Singleton<T>(const Singleton<T> &);
+ Singleton<T> &operator=(const Singleton<T> &);
- 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<T>::_singleton=0
+#define DECLARE_SINGLETON(T) template<> T *Common::Singleton<T>::_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 <class T, int MAX_SIZE = 10>
+template<class T, int MAX_SIZE = 10>
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 <class T>
+template<class T>
class Stack {
protected:
Array<T> _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];
}
};