Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

Table< T > Class Template Reference

#include <tables.H>

Inheritance diagram for Table< T >:

Tuple< T > Matrix< T > List of all members.

Detailed Description

template<class T>
class Table< T >

the Table class : 2-dimensional arrays

A 2-dimensional array of elements of type T may be defined using Tuple< Tuple<T> > M. It is even recommended when we want a "matrix with lines of different sizes". Elements may be accessed or modified via M(i)(j). Setting M.set_sep('
') assures that M displays quite well.

However, the operation of assignment, for example, is terribly slow and memory consuming. So we provide the Table class, which is optimized for this, and also improves various things like the way tables are displayed, the way elements are accessed, etc. This is achieved by defining a table of size (i,j) to be a tuple of size i*j together with a bunch of pointers to where the "lines" start.

The methods are similar to those of Tuple, so there are less comments.

Definition at line 256 of file tables.H.

Public Member Functions

 Table ()
 default constructor
 Table (long i, long j)
 constructor
 Table (const Table< T > &that)
 constructor
 ~Table ()
 destructor: releases memory
void resize (long i, long j)
 resize
void copy (const Table< T > &that)
 copy from another table
void steal (Table< T > &that)
 steal data
Table< T > operator= (const Table< T > &that)
 assigment operator =
void readline (long i, const Tuple< T > &line)
 loads a line from a Tuple
void get_data_from_tuple_list (const list< Tuple< T > > &L)
T & operator() (long i, long j)
 read or write data, eg x= M(i,j); or M(i,j)=5;
const T & operator() (long i, long j) const
long nlines () const
 current number of lines
long ncols () const
 current number of rows
void set_delim (char theleft, char theright)
 set delimiters (for display purposes)

Protected Member Functions

long col_width () const
 width of the largest column
void write_ptrs ()
 write "bookmarks"

Protected Attributes

T ** pdata
 pointers to the lines
long nb_lines
 self-evident
long nb_cols
 self-evident
char left
 chars printed on the borders
char right
 chars printed on the borders

Friends

ostream & operator<< (ostream &os, const Table< T > &M)
 displays the table with neatly aligned columns


Constructor & Destructor Documentation

template<class T>
Table< T >::Table  )  [inline]
 

default constructor

sets the size to 1 line, 1 row.

template<class T>
Table< T >::Table long  i,
long  j
[inline]
 

constructor

Parameters:
i=nb of lines, j=nb of rows

template<class T>
Table< T >::Table const Table< T > &  that  )  [inline]
 

constructor

template<class T>
Table< T >::~Table  )  [inline]
 

destructor: releases memory


Member Function Documentation

template<class T>
long Table< T >::col_width  )  const [inline, protected]
 

width of the largest column

for display purposes.

Returns:
the maximum width of an element, in chars.

Definition at line 270 of file tables.H.

template<class T>
void Table< T >::copy const Table< T > &  that  )  [inline]
 

copy from another table

Definition at line 366 of file tables.H.

Referenced by Table< Polynomial< K > >::operator=().

template<class T>
long Table< T >::ncols  )  const [inline]
 

current number of rows

Definition at line 445 of file tables.H.

Referenced by multiIdeal< K >::simplify().

template<class T>
long Table< T >::nlines  )  const [inline]
 

current number of lines

Definition at line 443 of file tables.H.

Referenced by DerivationAnalyzer::constant_subalgebra(), and HomFinder::set_hom_from_matrix().

template<class T>
T& Table< T >::operator() long  i,
long  j
[inline]
 

read or write data, eg x= M(i,j); or M(i,j)=5;

Definition at line 435 of file tables.H.

template<class T>
Table<T> Table< T >::operator= const Table< T > &  that  )  [inline]
 

assigment operator =

Definition at line 389 of file tables.H.

template<class T>
void Table< T >::readline long  i,
const Tuple< T > &  line
[inline]
 

loads a line from a Tuple

this assumes that "line" is large enough. Data is read to fill the specified line.

Parameters:
i: number of the line to write data in
line: tuple to read data from

Definition at line 402 of file tables.H.

template<class T>
void Table< T >::resize long  i,
long  j
[inline]
 

resize

Parameters:
i: new nb of lines,
j: new nb of cols

Definition at line 343 of file tables.H.

Referenced by DerivationAnalyzer::constant_subalgebra(), SW_Maker::create_regular_variables(), Chern_Maker::create_regular_variables(), Exponentiator< F_2 >::create_regular_variables(), multiIdeal< K >::grobnerize_with_coefficients(), and Ideal< F_2 >::grobnerize_with_coefficients().

template<class T>
void Table< T >::set_delim char  theleft,
char  theright
[inline]
 

set delimiters (for display purposes)

Definition at line 447 of file tables.H.

template<class T>
void Table< T >::steal Table< T > &  that  )  [inline]
 

steal data

Definition at line 376 of file tables.H.

Referenced by Matrix< Polynomial< K > >::operator *=().

template<class T>
void Table< T >::write_ptrs  )  [inline, protected]
 

write "bookmarks"

this fills in an array of pointers to the different "lines" in the table. Allows faster access. this assumes that pdata does not point to anything; a "new " operation is performed on pdata.

Definition at line 296 of file tables.H.

Referenced by Table< Polynomial< K > >::copy(), and Table< Polynomial< K > >::resize().


Friends And Related Function Documentation

template<class T>
ostream& operator<< ostream &  os,
const Table< T > &  M
[friend]
 

displays the table with neatly aligned columns

Definition at line 452 of file tables.H.


Member Data Documentation

template<class T>
char Table< T >::left [protected]
 

chars printed on the borders

Definition at line 263 of file tables.H.

Referenced by Table< Polynomial< K > >::copy().

template<class T>
long Table< T >::nb_cols [protected]
 

self-evident

Definition at line 261 of file tables.H.

Referenced by Table< Polynomial< K > >::copy(), Matrix< Polynomial< K > >::operator+=(), Matrix< Polynomial< K > >::operator-=(), and Table< Polynomial< K > >::steal().

template<class T>
long Table< T >::nb_lines [protected]
 

self-evident

Definition at line 261 of file tables.H.

Referenced by Table< Polynomial< K > >::copy(), Matrix< Polynomial< K > >::operator+=(), Matrix< Polynomial< K > >::operator-=(), and Table< Polynomial< K > >::steal().

template<class T>
T** Table< T >::pdata [protected]
 

pointers to the lines

Definition at line 259 of file tables.H.

Referenced by Table< Polynomial< K > >::steal().

template<class T>
char Table< T >::right [protected]
 

chars printed on the borders

Definition at line 263 of file tables.H.

Referenced by Table< Polynomial< K > >::copy().


The documentation for this class was generated from the following file:
Generated on Wed Jun 18 17:22:47 2008 for Pierre Guillot by  doxygen 1.3.9.1