Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes
vnl_scalar_join_iterator< T > Class Template Reference

Database join on matrix columns. More...

#include <vnl_scalar_join_iterator.h>

List of all members.

Public Member Functions

 vnl_scalar_join_iterator (const vnl_matrix< T > &relation1, unsigned column1, const vnl_matrix< T > &relation2, unsigned column2)
 Initialize this iterator to the join of relation1(:,column1) and relation2(:,column2).
 ~vnl_scalar_join_iterator ()
 Destructor.
 operator safe_bool () const
 Return true if all pairs have been seen.
bool operator! () const
 Return false if all pairs have been seen.
vnl_scalar_join_iterator< T > & operator++ ()
 Advance to the next pair. This is prefix ++.
bool done () const
void next ()
 Increment the iterator to point to the next pair of rows.
unsigned row1 () const
 Return the index of the current row in the first relation.
unsigned row2 () const
 Return the index of the current row in the second relation.

Protected Attributes

unsigned n1
unsigned n2
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > > * 
pI1
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > > * 
pI2
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > > & 
I1
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > > & 
I2
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > >::iterator 
index1
vcl_list
< vnl_scalar_join_iterator_indexed_pair
< T > >::iterator 
index2

Private Member Functions

vnl_scalar_join_iterator< T > operator++ (int)
 Postfix ++ should not be used. Only present for instantiation purposes.

Private Attributes

 VCL_SAFE_BOOL_DEFINE

Detailed Description

template<class T>
class vnl_scalar_join_iterator< T >

Database join on matrix columns.

vnl_scalar_join_iterator implements a fast database join on columns of matrices of scalars. "Scalar" here really means that the objects have comparison operators. The cost is O(n log n) where n is the number of rows, all for the two sorts in the ctor.

CAVEAT: The current implementation fudges multiple occurrences of the same key in the source column. For example,

    join  1 3 and  3 5 on columns 2 and 1 respectively
          2 3      3 6
   

should give

          1 3 3 5
          1 3 3 6
          2 3 3 5
          2 3 3 6
   

and it doesn't. Contact awf if you need this to work.

Definition at line 68 of file vnl_scalar_join_iterator.h.


Constructor & Destructor Documentation

template<class T >
vnl_scalar_join_iterator< T >::vnl_scalar_join_iterator ( const vnl_matrix< T > &  relation1,
unsigned  column1,
const vnl_matrix< T > &  relation2,
unsigned  column2 
)

Initialize this iterator to the join of relation1(:,column1) and relation2(:,column2).

The algorithm sorts an array of pointers to each row and traversal of the iterator runs through these to produce the join. After construction the row1() and row2() methods indicate the first pair.

Definition at line 49 of file vnl_scalar_join_iterator.txx.

template<class T >
vnl_scalar_join_iterator< T >::~vnl_scalar_join_iterator ( )

Destructor.

Definition at line 90 of file vnl_scalar_join_iterator.txx.


Member Function Documentation

template<class T >
bool vnl_scalar_join_iterator< T >::done ( ) const

Definition at line 97 of file vnl_scalar_join_iterator.txx.

template<class T >
void vnl_scalar_join_iterator< T >::next ( )

Increment the iterator to point to the next pair of rows.

Definition at line 104 of file vnl_scalar_join_iterator.txx.

template<class T>
vnl_scalar_join_iterator< T >::operator safe_bool ( ) const [inline]

Return true if all pairs have been seen.

Definition at line 94 of file vnl_scalar_join_iterator.h.

template<class T>
bool vnl_scalar_join_iterator< T >::operator! ( ) const [inline]

Return false if all pairs have been seen.

Definition at line 98 of file vnl_scalar_join_iterator.h.

template<class T>
vnl_scalar_join_iterator<T>& vnl_scalar_join_iterator< T >::operator++ ( ) [inline]

Advance to the next pair. This is prefix ++.

Definition at line 102 of file vnl_scalar_join_iterator.h.

template<class T >
vnl_scalar_join_iterator< T > vnl_scalar_join_iterator< T >::operator++ ( int  ) [private]

Postfix ++ should not be used. Only present for instantiation purposes.

Definition at line 154 of file vnl_scalar_join_iterator.txx.

template<class T >
unsigned vnl_scalar_join_iterator< T >::row1 ( ) const

Return the index of the current row in the first relation.

Definition at line 141 of file vnl_scalar_join_iterator.txx.

template<class T >
unsigned vnl_scalar_join_iterator< T >::row2 ( ) const

Return the index of the current row in the second relation.

Definition at line 147 of file vnl_scalar_join_iterator.txx.


Member Data Documentation

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >& vnl_scalar_join_iterator< T >::I1 [protected]

Definition at line 76 of file vnl_scalar_join_iterator.h.

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >& vnl_scalar_join_iterator< T >::I2 [protected]

Definition at line 77 of file vnl_scalar_join_iterator.h.

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >::iterator vnl_scalar_join_iterator< T >::index1 [protected]

Definition at line 78 of file vnl_scalar_join_iterator.h.

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >::iterator vnl_scalar_join_iterator< T >::index2 [protected]

Definition at line 79 of file vnl_scalar_join_iterator.h.

template<class T>
unsigned vnl_scalar_join_iterator< T >::n1 [protected]

Definition at line 72 of file vnl_scalar_join_iterator.h.

template<class T>
unsigned vnl_scalar_join_iterator< T >::n2 [protected]

Definition at line 73 of file vnl_scalar_join_iterator.h.

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >* vnl_scalar_join_iterator< T >::pI1 [protected]

Definition at line 74 of file vnl_scalar_join_iterator.h.

template<class T>
vcl_list<vnl_scalar_join_iterator_indexed_pair<T> >* vnl_scalar_join_iterator< T >::pI2 [protected]

Definition at line 75 of file vnl_scalar_join_iterator.h.

template<class T>
vnl_scalar_join_iterator< T >::VCL_SAFE_BOOL_DEFINE [private]

Definition at line 70 of file vnl_scalar_join_iterator.h.


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