Template vector

o EST_TVector

This serves as a base class for a vector of type <type>T</type>. This acts as a higher level version of a normal C array as defined as <type>float *x</type> etc.

The vector can be resized after declaration, access can be with or without bounds checking. Round brackets denote read-only access (for consts) while square brackets are for read-write access. In both cases references are returned.

The standard operators () and [] should be thought of as having no bounds checking, though they may do so optionally as a compile time option. The methods <method>a_check</method> and <method>a_nocheck</method> provide explicit boundary checking/nonchecking, both const and non-const versions are provided.

Access through () and [] are guaranteed to be as fast as standard C arrays (assuming a resonable optimizing compiler).

<programlisting> EST_FVector x(10); int i;

for (i=0; i < x.length(); ++i) x[i] = sqrt((float)i);

x.resize(20);

for (i=10; i < x.length(); ++i) x[i] = sqrt((float)i);

</programlisting>

To instantialte a template for a a vector of type {FooBar}

<programlisting> include "../base_class/EST_TVector.cc"// If you want List to vector convertion (and defined a TList) include "../base_class/EST_Tvectlist.cc" template class EST_TVector<FooBar>; template ostream& operator << (ostream &st, const EST_TVector<FooBar> &v); </programlisting>

The EST library already has template vector instantiations for <type>int</type>, <type>float</type>, <type>double</type> and <docppRef linkend='EST_String'>. Also types are defined for them in <docppRef linkend='EST_types.h'> as <docppRef linkend='EST_IVector'>, <docppRef linkend='EST_FVector'>, <docppRef linkend='EST_DVector'> and <docppRef linkend='EST_StrVector'> for <type>int</type>s, <type>float</type>s, <type>doubles</type>s and <docppRef linkend='EST_String'>s respectively.

See Also:
matrix_example

Alphabetic index Hierarchy of classes


This page is part of the Edinburgh Speech Tools Library documentation
Copyright University of Edinburgh 1997
Contact: speech_tools@cstr.ed.ac.uk