Subversion Repositories spk

Rev

Rev 111 | Rev 113 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 111 Rev 112
Line 4... Line 4...
4
#include "../spkdll.h"
4
#include "../spkdll.h"
5
#include <vector>
5
#include <vector>
6
 
6
 
7
//namespace SPK {
7
//namespace SPK {
8
namespace Utils {
8
namespace Utils {
-
 
9
 
9
 
10
 
10
	template <class T>
11
	template <class T>
11
	class SPKEXPORT CList
12
	class CList
12
	{
13
	{
-
 
14
	public:
-
 
15
		typedef typename std::vector<T *>::iterator iterator ;
-
 
16
 
13
	private:
17
	private:
14
		std::vector<T *> *_lItems;
18
		std::vector<T *> *_lItems;
15
		bool			 _bDontClear;
19
		bool			 _bDontClear;
16
		typename std::vector<T *>::iterator _pItr;
20
		typename std::vector<T *>::iterator _pItr;
17
 
21
 
Line 20... Line 24...
20
		~CList();
24
		~CList();
21
 
25
 
22
		void clear();
26
		void clear();
23
		T *push_back(T *pItem);
27
		T *push_back(T *pItem);
24
 
28
 
25
		typename std::vector<T *>::iterator begin();
29
		iterator begin();
26
		typename std::vector<T *>::iterator end();
30
		iterator end();
27
		T *first();
31
		T *first();
28
		T *next();
32
		T *next();
29
 
33
 
30
		bool empty() const;
34
		bool empty() const;
-
 
35
		size_t size() const;
31
	};
36
	};
32
 
37
 
33
 
38
 
34
	///////////////////////////////////////////////////////////////////////////
39
	///////////////////////////////////////////////////////////////////////////
35
 
40
 
36
	template<class T>
41
	template<class T>
37
	CList<T>::CList(bool bDontClear) : _bDontClear(bDontClear)
42
	CList<T>::CList(bool bDontClear) : _bDontClear(bDontClear)
38
	{
43
	{
39
		_lItems = new std::vector<T *>();
44
		_lItems = new std::vector<T *>();
40
		_pItr = _lItems->end();
45
		_pItr = _lItems->end();
Line 62... Line 67...
62
	template <class T>
67
	template <class T>
63
	T *CList<T>::push_back(T *pItem)
68
	T *CList<T>::push_back(T *pItem)
64
	{
69
	{
65
		_lItems->push_back(pItem);
70
		_lItems->push_back(pItem);
66
		return pItem;
71
		return pItem;
67
	}
72
	}
68
 
73
 
69
 
74
 
70
	template <class T>
75
	template <class T>
71
	typename std::vector<T *>::iterator CList<T>::begin()
76
	typename CList<T>::iterator CList<T>::begin()
72
	{
77
	{
73
		return _lItems->begin();
78
		return _lItems->begin();
74
	}
79
	}
75
 
80
 
76
	template <class T>
81
	template <class T>
77
	typename std::vector<T *>::iterator CList<T>::end()
82
	typename CList<T>::iterator CList<T>::end()
78
	{
83
	{
79
		return _lItems->end();
84
		return _lItems->end();
80
	}
85
	}
81
 
86
 
82
	template <class T>
87
	template <class T>
83
	T *CList<T>::first()
88
	T *CList<T>::first()
84
	{
89
	{
85
		if ( _lItems->empty() ) return NULL;
90
		if ( _lItems->empty() ) return NULL;
86
		_pItr = _lItems->begin();
91
		_pItr = _lItems->begin();
87
		return *_pItr;
92
		return *_pItr;
88
	}
93
	}
89
 
94
 
90
	template <class T>
95
	template <class T>
91
	T *CList<T>::next()
96
	T *CList<T>::next()
92
	{
97
	{
93
		if ( _lItems->empty() ) return NULL;
98
		if ( _lItems->empty() ) return NULL;
94
		if ( _pItr == _lItems->end() ) return NULL;
99
		if ( _pItr == _lItems->end() ) return NULL;
95
		++_pItr;
100
		++_pItr;
96
		if ( _pItr == _lItems->end() ) return NULL;
101
		if ( _pItr == _lItems->end() ) return NULL;
97
		return *_pItr;
102
		return *_pItr;
98
	}
103
	}
99
 
104
 
100
	template <class T>
105
	template <class T>
101
	bool CList<T>::empty() const
106
	bool CList<T>::empty() const
-
 
107
	{
-
 
108
		return _lItems->empty();
-
 
109
	}
-
 
110
 
-
 
111
	template <class T>
-
 
112
	size_t CList<T>::size() const
102
	{
113
	{
103
		return _lItems->empty();
114
		return _lItems->size();
104
	}
115
	}
105
}
116
}
106
//}
117
//}
107
 
118
 
108
#endif //__LIST_H__
119
#endif //__LIST_H__