proj home

Files   Classes   Functions   Hierarchy  

bucketlink< T > Class Template Reference

: Used by class bucket. This is a linked list class. More...

#include <bucketlink.h>

Inheritance diagram for bucketlink< T >:
Collaboration diagram for bucketlink< T >:

List of all members.

Public Member Functions

 bucketlink ()
 Construct an empty link.
 bucketlink (T *data_)
 Construct with data.
template<typename I2 >
void insertafterself (bucketlink< T > *b, I2 &fn)
 Insert the link in the list in order.

Public Attributes

Tdata
 Hold the data.
bucketlinknext
 The next link in the chain.

Static Public Attributes

static uint insertafterselfcounter = 0
 Set to zero before inserting, then you can compare after insertion to see the chain length.


Detailed Description

template<typename T>
class bucketlink< T >

: Used by class bucket. This is a linked list class.

Definition at line 22 of file bucketlink.h.


Constructor & Destructor Documentation

template<typename T>
bucketlink< T >::bucketlink (  )  [inline]

Construct an empty link.

Definition at line 33 of file bucketlink.h.

00034     : data(0), next(0) 
00035     {}

template<typename T>
bucketlink< T >::bucketlink ( T data_  )  [inline]

Construct with data.

Definition at line 37 of file bucketlink.h.

00038     : data(data_), next(0)
00039     {}


Member Function Documentation

template<typename T>
template<typename I2 >
void bucketlink< T >::insertafterself ( bucketlink< T > *  b,
I2 &  fn 
) [inline]

Insert the link in the list in order.

This routine can only insert after itself and not before.

Definition at line 61 of file bucketlink.h.

References bucketlink< T >::data, bucketlink< T >::insertafterselfcounter, bucketlink< T >::next, and SHOW.

Referenced by buckethybrid< T, HFN, C >::eval(), and bucket< T, HFN >::eval().

00062 {
00063   assert(b!=0);
00064   assert( fn(*(b->data),*(this->data))==false );
00065 
00066 insertafterselfcounter=0;
00067 
00068   bucketlink<T>* cp = next;
00069   bucketlink<T>* cp0 = this;
00070   for ( ;cp!=0; )
00071   {
00072 
00073     ++insertafterselfcounter;
00074 #ifdef DEBUG_BUCKETLINK
00075 cout << SHOW(insertafterselfcounter) << endl;
00076 #endif
00077 
00078     if (fn(*(b->data),*(cp->data)))
00079     {
00080       b->next = cp;
00081       cp0->next = b;
00082       return;
00083     }
00084 
00085     cp0 = cp;
00086     cp = cp->next;
00087   }
00088 
00089   // Insert at the end of the list.
00090   cp0->next = b;
00091   b->next=0;
00092 }


Member Data Documentation

template<typename T>
T* bucketlink< T >::data

template<typename T>
uint bucketlink< T >::insertafterselfcounter = 0 [inline, static]

Set to zero before inserting, then you can compare after insertion to see the chain length.

Definition at line 43 of file bucketlink.h.

Referenced by bucketlink< T >::insertafterself().

template<typename T>
bucketlink* bucketlink< T >::next


The documentation for this class was generated from the following file:

Generated on Fri Mar 4 00:49:51 2011 for Chelton Evans Source by  doxygen 1.5.8