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

Tuple< T > Class Template Reference

#include <tables.H>

Inheritance diagram for Tuple< T >:

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

Detailed Description

template<class T>
class Tuple< T >

the Tuple class: n-tuples

The class Tuple represents an n-tuple of elements of type T, where n can be dynamically adjusted. It is meant to be a light, simple replacement for regular arrays.

Definition at line 27 of file tables.H.

Public Member Functions

 Tuple ()
 default constructor
 Tuple (long thesize)
 constructor
 Tuple (const Tuple< T > &that)
 ~Tuple ()
 destructor: releases memory.
void block_copy (T *dest, const T *source, long amount)
void resize (long thesize)
 dynamically resize
void copy (const Tuple< T > &that)
 copy of another tuple
Tuple< T > & operator= (const Tuple< T > &that)
 asignment operator =
void steal (Tuple< T > &that)
 steal data
long size () const
 returns the current size (tuple_size)
void set_sep (const char s)
 sets the separator which is used when displaying. 0 means no separation.
T & operator[] (long i)
 reading or writing data
const T & operator[] (long i) const
bool operator== (const Tuple< T > &that) const
 compares tuples

Protected Attributes

long tuple_size
 current size of the n-tuple (n, what.)
T * data
 pointer to the data itself
char sep
 separator, when printing. 0 means no separation.

Friends

ostream & operator<< (ostream &os, const Tuple< T > &M)
 prints a tuple on a stream
ofstream & operator<< (ofstream &file, Tuple< T > &M)
 write to file
void operator>> (ifstream &file, Tuple< T > &M)
 read from file


Constructor & Destructor Documentation

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

default constructor

sets the size to 0.

template<class T>
Tuple< T >::Tuple long  thesize  )  [inline]
 

constructor

Parameters:
thesize: initial size of the tuple

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

destructor: releases memory.


Member Function Documentation

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

copy of another tuple

the size of the tuple is adjusted, and data is copied into it from "that"

Parameters:
that: another tuple.

Definition at line 103 of file tables.H.

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

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

asignment operator =

the size of the tuple is adjusted, and data is copied into it from "that"

Parameters:
that: another tuple.

Definition at line 119 of file tables.H.

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

compares tuples

Definition at line 172 of file tables.H.

template<class T>
T& Tuple< T >::operator[] long  i  )  [inline]
 

reading or writing data

this returns the T object at position i, and it may be used on the left or right of an assignement with =.

Parameters:
i:index,must between 0 and tuple_size-1
  Tuple<int> v(7);
  v[5]=-3;

Definition at line 163 of file tables.H.

template<class T>
void Tuple< T >::resize long  thesize  )  [inline]
 

dynamically resize

so far, no mechanism in case there isn't enough memory. resizing is of course quite slow and memory consuming, so use with moderation.

Parameters:
thesize: new size required.

Definition at line 84 of file tables.H.

Referenced by Exponentiator< F_2 >::compute_lambda_relation(), Exponentiator< F_2 >::compute_tensor_relation(), Exponentiator< F_2 >::create_extra_variables(), AffineAlgebra< F_2 >::get_variables(), GradedAlgebra< F_2 >::list_monomials(), PowProd::operator/=(), MilnorAnalyzer::re_setup(), RepresentationRing::read_variables(), HomFinder::restrict_to_elemab(), DerivationAnalyzer::setup(), MilnorAnalyzer::setup_for_Sq1(), PowProd::shift(), PowProd::swap(), GradedAlgebra< F_2 >::top_degree(), and UnstableAlgebra::write_trivial_steenrod_operations().

template<class T>
void Tuple< T >::set_sep const char  s  )  [inline]
 

sets the separator which is used when displaying. 0 means no separation.

Definition at line 148 of file tables.H.

Referenced by multiPolynomial< F_2 >::multiPolynomial().

template<class T>
long Tuple< T >::size  )  const [inline]
 

returns the current size (tuple_size)

Definition at line 146 of file tables.H.

Referenced by DerivationAnalyzer::constant_subalgebra(), DerivationAnalyzer::coords_of(), HomFinder::define_polynomial_variables(), HomFinder::define_polynomial_variables_brutally(), PowProd::degree(), PowProd::divides(), multiPolynomial< F_2 >::divides(), GradedAlgebra< F_2 >::even_subalgebra(), multiPolynomial< F_2 >::lc(), multiPolynomial< F_2 >::lc_POT(), GradedAlgebra< F_2 >::list_monomials(), multiPolynomial< F_2 >::lm(), multiPolynomial< F_2 >::lm_POT(), multiPolynomial< F_2 >::lp(), multiPolynomial< F_2 >::lp_POT(), PowProd::nvars(), multiPolynomial< F_2 >::operator/(), PowProd::operator/=(), PowProd::power_of(), MilnorAnalyzer::re_setup(), MilnorAnalyzer::setup_for_Sq1(), PowProd::shift(), and PowProd::swap().

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

steal data

If a and b are tuples, and if you use a.steal(b), then a becomes what b was, while b is emptied.

Point: no copy of memory is performed, so the operation is extremely fast.

This may be used for example to swap x and y efficiently: simply use

 dummy.steal(x); x.steal(y); y.steal(dummy);

Definition at line 136 of file tables.H.

Referenced by Table< Polynomial< K > >::steal(), UnstableAlgebra::swap_variables_order(), and RepresentationRing::swap_variables_order().


Friends And Related Function Documentation

template<class T>
ofstream& operator<< ofstream &  file,
Tuple< T > &  M
[friend]
 

write to file

Definition at line 216 of file tables.H.

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

prints a tuple on a stream

this assumes that objects of type T sent to os!

Parameters:
os: a stream such as cout or cerr,
M: the tuple to print.
  Tuple<long> M(12);
  cout << "value of M: " << M;

Definition at line 196 of file tables.H.

template<class T>
void operator>> ifstream &  file,
Tuple< T > &  M
[friend]
 

read from file

Definition at line 224 of file tables.H.


Member Data Documentation

template<class T>
T* Tuple< T >::data [protected]
 

pointer to the data itself

Definition at line 33 of file tables.H.

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

template<class T>
char Tuple< T >::sep [protected]
 

separator, when printing. 0 means no separation.

Definition at line 35 of file tables.H.

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

template<class T>
long Tuple< T >::tuple_size [protected]
 

current size of the n-tuple (n, what.)

Definition at line 31 of file tables.H.

Referenced by Tuple< Polynomial< K > >::copy(), Tuple< Polynomial< K > >::operator==(), and Tuple< Polynomial< K > >::steal().


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