From a9a46e20b210519458c40ac3b88e37da7bf9d8be Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Wed, 24 Mar 2004 18:34:47 +0000 Subject: [PATCH] fixed size() function, added empty() function --- amxmodx/CList.h | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/amxmodx/CList.h b/amxmodx/CList.h index ce13a94e..db2bf0f7 100755 --- a/amxmodx/CList.h +++ b/amxmodx/CList.h @@ -51,21 +51,28 @@ public: }; private: CListEle *head; - int cur_size; public: - CList() { head = 0; cur_size = 0; } + CList() { head = 0; } ~CList() { clear(); } void clear() { iterator a = begin(); while( a ) a.remove(); - cur_size = 0; + } + bool empty() { + return (head ? false : true); } void put( T* a ) { head = new CListEle( a , head ); - ++cur_size; } int size() { - return cur_size; + CListEle *p = head; + int i = 0; + while (p) + { + p = p->next; + ++i; + } + return i; } class iterator { CListEle** a;