GClasses
GClasses::GRelationalTable< T, Comp > Class Template Reference

Detailed Description

template<typename T, typename Comp>
class GClasses::GRelationalTable< T, Comp >

See GTree.cpp for an example of how to use this class.

#include <GTree.h>

Public Member Functions

 GRelationalTable (const Comp &c)
 
 ~GRelationalTable ()
 
void clear ()
 Drops all content from this table. More...
 
GRelationalRow< T > * find (const T &row, size_t col, size_t *outIndex=NULL)
 Returns a row where the element in column col matches the one in the provided row. Returns NULL if no matches exist. If outIndex is non-NULL, it will be made to point to the index of the returned row when sorted in column col. More...
 
GRelationalRow< T > * firstEqualOrGreater (const T &row, size_t col, size_t *outIndex=NULL)
 Returns the first occurrence of a row where the element in column col is equal or greater than the one in the provided row. Returns NULL if no rows contain an element in column col greater than the one in row. If outIndex is non-NULL, it will be made to point to the index of the returned row when sorted in column col. More...
 
GRelationalRow< T > * get (size_t n, size_t col)
 Returns the nth row when the rows are sorted by column col. More...
 
void insert (const T &row)
 Inserts a row into this relational table. More...
 
void print (std::ostream &stream, size_t col)
 Prints a simple representation of the tree in the specified column. This method assumes that the Comp object has a method with the signature "void print(std::ostream& stream, T) const". More...
 
void remove (GRelationalRow< T > *row)
 Removes the specified row from this relational table. (Behavior is undefined if the specified row is not actually in the table.) More...
 
size_t size ()
 Returns the number of rows in this relational table. More...
 

Protected Attributes

const Comp & comp
 
GRelationalRow< T > ** roots
 
GRelationalRow< T > * spare
 

Constructor & Destructor Documentation

template<typename T , typename Comp >
GClasses::GRelationalTable< T, Comp >::GRelationalTable ( const Comp &  c)
inline
template<typename T , typename Comp >
GClasses::GRelationalTable< T, Comp >::~GRelationalTable ( )
inline

Member Function Documentation

template<typename T , typename Comp >
void GClasses::GRelationalTable< T, Comp >::clear ( )
inline

Drops all content from this table.

template<typename T , typename Comp >
GRelationalRow<T>* GClasses::GRelationalTable< T, Comp >::find ( const T &  row,
size_t  col,
size_t *  outIndex = NULL 
)
inline

Returns a row where the element in column col matches the one in the provided row. Returns NULL if no matches exist. If outIndex is non-NULL, it will be made to point to the index of the returned row when sorted in column col.

template<typename T , typename Comp >
GRelationalRow<T>* GClasses::GRelationalTable< T, Comp >::firstEqualOrGreater ( const T &  row,
size_t  col,
size_t *  outIndex = NULL 
)
inline

Returns the first occurrence of a row where the element in column col is equal or greater than the one in the provided row. Returns NULL if no rows contain an element in column col greater than the one in row. If outIndex is non-NULL, it will be made to point to the index of the returned row when sorted in column col.

template<typename T , typename Comp >
GRelationalRow<T>* GClasses::GRelationalTable< T, Comp >::get ( size_t  n,
size_t  col 
)
inline

Returns the nth row when the rows are sorted by column col.

template<typename T , typename Comp >
void GClasses::GRelationalTable< T, Comp >::insert ( const T &  row)
inline

Inserts a row into this relational table.

template<typename T , typename Comp >
void GClasses::GRelationalTable< T, Comp >::print ( std::ostream &  stream,
size_t  col 
)
inline

Prints a simple representation of the tree in the specified column. This method assumes that the Comp object has a method with the signature "void print(std::ostream& stream, T) const".

template<typename T , typename Comp >
void GClasses::GRelationalTable< T, Comp >::remove ( GRelationalRow< T > *  row)
inline

Removes the specified row from this relational table. (Behavior is undefined if the specified row is not actually in the table.)

template<typename T , typename Comp >
size_t GClasses::GRelationalTable< T, Comp >::size ( )
inline

Returns the number of rows in this relational table.

Member Data Documentation

template<typename T , typename Comp >
const Comp& GClasses::GRelationalTable< T, Comp >::comp
protected
template<typename T , typename Comp >
GRelationalRow<T>** GClasses::GRelationalTable< T, Comp >::roots
protected
template<typename T , typename Comp >
GRelationalRow<T>* GClasses::GRelationalTable< T, Comp >::spare
protected