Public Member Functions | Protected Attributes | Private Member Functions | List of all members
vnl_scalar_join_iterator< T > Class Template Reference

Database join on matrix columns. More...

#include <vnl_scalar_join_iterator.h>

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). More...
 
 ~vnl_scalar_join_iterator ()
 Destructor. More...
 
 operator bool () const
 Return true if all pairs have been seen. More...
 
bool operator! () const
 Return false if all pairs have been seen. More...
 
vnl_scalar_join_iterator< T > & operator++ ()
 Advance to the next pair. This is prefix ++. More...
 
bool done () const
 
void next ()
 Increment the iterator to point to the next pair of rows. More...
 
unsigned row1 () const
 Return the index of the current row in the first relation. More...
 
unsigned row2 () const
 Return the index of the current row in the second relation. More...
 

Protected Attributes

unsigned n1
 
unsigned n2
 
std::list< vnl_scalar_join_iterator_indexed_pair< T > > * pI1
 
std::list< vnl_scalar_join_iterator_indexed_pair< T > > * pI2
 
std::list< vnl_scalar_join_iterator_indexed_pair< T > > & I1
 
std::list< vnl_scalar_join_iterator_indexed_pair< T > > & I2
 
std::list< vnl_scalar_join_iterator_indexed_pair< T > >::iterator index1
 
std::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. More...
 

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 69 of file vnl_scalar_join_iterator.h.

Constructor & Destructor Documentation

◆ vnl_scalar_join_iterator()

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 51 of file vnl_scalar_join_iterator.hxx.

◆ ~vnl_scalar_join_iterator()

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

Destructor.

Definition at line 92 of file vnl_scalar_join_iterator.hxx.

Member Function Documentation

◆ done()

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

Definition at line 99 of file vnl_scalar_join_iterator.hxx.

◆ next()

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

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

Definition at line 106 of file vnl_scalar_join_iterator.hxx.

◆ operator bool()

template<class T>
vnl_scalar_join_iterator< T >::operator bool ( ) const
inlineexplicit

Return true if all pairs have been seen.

Definition at line 96 of file vnl_scalar_join_iterator.h.

◆ operator!()

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

Return false if all pairs have been seen.

Definition at line 100 of file vnl_scalar_join_iterator.h.

◆ operator++() [1/2]

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 104 of file vnl_scalar_join_iterator.h.

◆ operator++() [2/2]

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 156 of file vnl_scalar_join_iterator.hxx.

◆ row1()

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 143 of file vnl_scalar_join_iterator.hxx.

◆ row2()

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 149 of file vnl_scalar_join_iterator.hxx.

Member Data Documentation

◆ I1

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >& vnl_scalar_join_iterator< T >::I1
protected

Definition at line 78 of file vnl_scalar_join_iterator.h.

◆ I2

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >& vnl_scalar_join_iterator< T >::I2
protected

Definition at line 79 of file vnl_scalar_join_iterator.h.

◆ index1

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >::iterator vnl_scalar_join_iterator< T >::index1
protected

Definition at line 80 of file vnl_scalar_join_iterator.h.

◆ index2

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >::iterator vnl_scalar_join_iterator< T >::index2
protected

Definition at line 81 of file vnl_scalar_join_iterator.h.

◆ n1

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

Definition at line 74 of file vnl_scalar_join_iterator.h.

◆ n2

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

Definition at line 75 of file vnl_scalar_join_iterator.h.

◆ pI1

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >* vnl_scalar_join_iterator< T >::pI1
protected

Definition at line 76 of file vnl_scalar_join_iterator.h.

◆ pI2

template<class T>
std::list<vnl_scalar_join_iterator_indexed_pair<T> >* vnl_scalar_join_iterator< T >::pI2
protected

Definition at line 77 of file vnl_scalar_join_iterator.h.


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