make gcc-2.95 happy

This commit is contained in:
Olaf Rempel 2006-04-17 13:35:50 +02:00
parent 7811f0ab16
commit 68fea83c6f
2 changed files with 91 additions and 77 deletions

View File

@ -55,6 +55,8 @@ private:
List<GameEntry> buckets[MAX_BUCKETS];
int timeout;
friend class GameList::GameListIterator;
};
#endif // _GAMELIST_H_

62
list.h
View File

@ -35,8 +35,13 @@ template <class T>
class ListEntry;
template <class T>
class ListIterator;
template <class T>
class List {
friend class ListIterator<T>;
public:
List() : head(0), tail(0) {}
~List() {}
@ -91,10 +96,16 @@ protected:
List(const List& l);
List& operator=(const List& l);
template <class TT>
class ListIterator : public Iterator<TT> {
public:
ListIterator(List<TT>* list)
private:
ListEntry<T> *head;
ListEntry<T> *tail;
};
template <class T>
class ListIterator : public Iterator<T> {
public:
ListIterator(List<T>* list)
: list(list)
{
reset();
@ -107,11 +118,11 @@ protected:
return (pos == NULL) ? (list->head != NULL) : (pos->next != NULL);
}
virtual TT* next()
virtual T* next()
{
prev = pos;
pos = (pos == NULL) ? list->head : pos->next;
return (TT*)pos;
return (T*)pos;
}
virtual void remove()
@ -141,27 +152,22 @@ protected:
prev = NULL;
}
protected:
protected:
ListIterator(const ListIterator& li);
ListIterator& operator=(const ListIterator& li);
List<TT>* list;
private:
ListEntry<TT>* pos;
ListEntry<TT>* prev;
};
List<T>* list;
private:
ListEntry<T> *head;
ListEntry<T> *tail;
ListEntry<T>* pos;
ListEntry<T>* prev;
};
template <class T>
class ListEntry {
friend class List<T>;
friend class List<T>::ListIterator<T>;
friend class ListIterator<T>;
public:
ListEntry() {}
~ListEntry() {}
@ -171,8 +177,13 @@ private:
};
template <class T>
class LockedListIterator;
template <class T>
class LockedList : private List<T> {
friend class LockedListIterator<T>;
public:
LockedList() {}
~LockedList() {}
@ -210,22 +221,23 @@ public:
}
private:
template <class TT>
class LockedListIterator : public List<TT>::ListIterator<TT> {
public:
LockedListIterator(LockedList<TT>* list)
: List<TT>::ListIterator<TT>(list)
Mutex mutex;
};
template <class T>
class LockedListIterator : public ListIterator<T> {
public:
LockedListIterator(LockedList<T>* list)
: ListIterator<T>(list)
{
list->mutex.lock();
}
virtual ~LockedListIterator()
{
((LockedList<TT>*)list)->mutex.unlock();
((LockedList<T>*)list)->mutex.unlock();
}
};
Mutex mutex;
};
#endif //_LIST_H_