aboutsummaryrefslogtreecommitdiff
path: root/src/list.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-10-14 23:26:25 +0000
committerMike Buland <eichlan@xagasoft.com>2010-10-14 23:26:25 +0000
commit867dae89929a11a421ec21af71d494ad0ecc1963 (patch)
tree85d4330d5cdc0567194f1bfb2f9b1bda4e95b444 /src/list.h
parent13fa07280dd9ed2c62ad2be0848f88b0d85fe322 (diff)
downloadlibbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.gz
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.bz2
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.tar.xz
libbu++-867dae89929a11a421ec21af71d494ad0ecc1963.zip
SharedCore has more features now, which is cool, including a test to see if
another object of the parent type has the same core, and another to clone the parent object. That one is pretty cool, it means you can now get a real copy when you want to, great for multi-threaded stuff. Also, two more classes are now SharedCore: Hash and Heap!
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/list.h b/src/list.h
index 9b95983..ba1d2c4 100644
--- a/src/list.h
+++ b/src/list.h
@@ -24,10 +24,18 @@ namespace Bu
24 ListLink *pPrev; 24 ListLink *pPrev;
25 }; 25 };
26 26
27 template<typename value, typename valuealloc, 27 template<typename value, typename valuealloc, typename linkalloc>
28 typename linkalloc> 28 class List;
29
30 template<typename value, typename valuealloc, typename linkalloc>
29 struct ListCore 31 struct ListCore
30 { 32 {
33 friend class List<value, valuealloc, linkalloc>;
34 friend class SharedCore<
35 List<value, valuealloc, linkalloc>,
36 ListCore<value, valuealloc, linkalloc>
37 >;
38 private:
31 typedef struct ListLink<value> Link; 39 typedef struct ListLink<value> Link;
32 ListCore() : 40 ListCore() :
33 pFirst( NULL ), 41 pFirst( NULL ),
@@ -193,8 +201,10 @@ namespace Bu
193 */ 201 */
194 template<typename value, typename valuealloc=std::allocator<value>, 202 template<typename value, typename valuealloc=std::allocator<value>,
195 typename linkalloc=std::allocator<struct ListLink<value> > > 203 typename linkalloc=std::allocator<struct ListLink<value> > >
196 class List : public SharedCore< struct ListCore<value, valuealloc, 204 class List : public SharedCore<
197 linkalloc> > 205 List<value, valuealloc, linkalloc>,
206 ListCore<value, valuealloc, linkalloc>
207 >
198 { 208 {
199 private: 209 private:
200 typedef struct ListLink<value> Link; 210 typedef struct ListLink<value> Link;
@@ -202,9 +212,9 @@ namespace Bu
202 typedef struct ListCore<value, valuealloc, linkalloc> Core; 212 typedef struct ListCore<value, valuealloc, linkalloc> Core;
203 213
204 protected: 214 protected:
205 using SharedCore< Core >::core; 215 using SharedCore<MyType, Core>::core;
206 using SharedCore< Core >::_hardCopy; 216 using SharedCore<MyType, Core>::_hardCopy;
207 using SharedCore< Core >::_allocateCore; 217 using SharedCore<MyType, Core>::_allocateCore;
208 218
209 public: 219 public:
210 struct const_iterator; 220 struct const_iterator;
@@ -215,7 +225,7 @@ namespace Bu
215 } 225 }
216 226
217 List( const MyType &src ) : 227 List( const MyType &src ) :
218 SharedCore< Core >( src ) 228 SharedCore<MyType, Core >( src )
219 { 229 {
220 } 230 }
221 231