summaryrefslogtreecommitdiff
path: root/src/list.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-02-20 08:07:31 +0000
committerMike Buland <eichlan@xagasoft.com>2008-02-20 08:07:31 +0000
commit3cea09281c9f809fc78de6f2e79f4117976f74e4 (patch)
tree7dccb751019a38bf93bffce61e5683d72a1fe842 /src/list.h
parenta4c22303b1044eee5ccbf0766895a879a8f4810e (diff)
downloadlibbu++-3cea09281c9f809fc78de6f2e79f4117976f74e4.tar.gz
libbu++-3cea09281c9f809fc78de6f2e79f4117976f74e4.tar.bz2
libbu++-3cea09281c9f809fc78de6f2e79f4117976f74e4.tar.xz
libbu++-3cea09281c9f809fc78de6f2e79f4117976f74e4.zip
Applied an update from Hash to Set (they're basically the same logic/code, in
fact, I need to get in there and change all the comments and exceptions in Set to refer to Set and not Hash). Util has the functors in it that are shared now, and List actually uses those functors for it's insertSorted function, that thing has come in so handy.
Diffstat (limited to 'src/list.h')
-rw-r--r--src/list.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/list.h b/src/list.h
index d8ddd08..30edf71 100644
--- a/src/list.h
+++ b/src/list.h
@@ -10,6 +10,7 @@
10 10
11#include <memory> 11#include <memory>
12#include "bu/exceptionbase.h" 12#include "bu/exceptionbase.h"
13#include "bu/util.h"
13 14
14namespace Bu 15namespace Bu
15{ 16{
@@ -34,12 +35,14 @@ namespace Bu
34 *@param linkalloc (typename) Memory Allocator for the list links. 35 *@param linkalloc (typename) Memory Allocator for the list links.
35 *@ingroup Containers 36 *@ingroup Containers
36 */ 37 */
37 template<typename value, typename valuealloc=std::allocator<value>, typename linkalloc=std::allocator<struct ListLink<value> > > 38 template<typename value, typename cmpfunc=__basicGTCmp<value>,
39 typename valuealloc=std::allocator<value>,
40 typename linkalloc=std::allocator<struct ListLink<value> > >
38 class List 41 class List
39 { 42 {
40 private: 43 private:
41 typedef struct ListLink<value> Link; 44 typedef struct ListLink<value> Link;
42 typedef class List<value, valuealloc, linkalloc> MyType; 45 typedef class List<value, cmpfunc, valuealloc, linkalloc> MyType;
43 46
44 public: 47 public:
45 List() : 48 List() :
@@ -189,7 +192,7 @@ namespace Bu
189 Link *pCur = pFirst; 192 Link *pCur = pFirst;
190 for(;;) 193 for(;;)
191 { 194 {
192 if( !(v > *(pCur->pValue)) ) 195 if( !cmp( v, *(pCur->pValue)) )
193 { 196 {
194 pNew->pNext = pCur; 197 pNew->pNext = pCur;
195 pNew->pPrev = pCur->pPrev; 198 pNew->pPrev = pCur->pPrev;
@@ -218,7 +221,7 @@ namespace Bu
218 */ 221 */
219 typedef struct iterator 222 typedef struct iterator
220 { 223 {
221 friend class List<value, valuealloc, linkalloc>; 224 friend class List<value, cmpfunc, valuealloc, linkalloc>;
222 private: 225 private:
223 Link *pLink; 226 Link *pLink;
224 MyType &rList; 227 MyType &rList;
@@ -357,7 +360,7 @@ namespace Bu
357 */ 360 */
358 typedef struct const_iterator 361 typedef struct const_iterator
359 { 362 {
360 friend class List<value, valuealloc, linkalloc>; 363 friend class List<value, cmpfunc, valuealloc, linkalloc>;
361 private: 364 private:
362 Link *pLink; 365 Link *pLink;
363 const MyType &rList; 366 const MyType &rList;
@@ -584,6 +587,7 @@ namespace Bu
584 linkalloc la; 587 linkalloc la;
585 valuealloc va; 588 valuealloc va;
586 int nSize; 589 int nSize;
590 cmpfunc cmp;
587 }; 591 };
588} 592}
589 593