<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Template vector</TITLE> <META NAME="GENERATOR" CONTENT="DOC++ 3.4.6"> </HEAD> <body bgcolor="#ffffff" link="#0000ff" vlink="#dd0000" text="#000088" alink="9000ff"> <A HREF = "http://www.cstr.ed.ac.uk/"> <IMG align=left BORDER=0 SRC = "cstr.gif"></A> <A HREF="http://www.cstr.ed.ac.uk/projects/speech_tools.html"> <IMG BORDER=0 ALIGN=right SRC="est.jpg" width=150 height=93></A> <br> <br clear=left> <p align=right> <TABLE BORDER=0><TR> <TD VALIGN=TOP><H2> <A HREF="#DOC.DOCU">Template vector</A></H2></TD></H2></TD></TR></TABLE> <TABLE> <TR><TD VALIGN=TOP> <IMG ALT="o" BORDER=0 SRC=icon1.gif><A NAME="EST_TVector"></A> <A HREF=EST_TVector.html><B>EST_TVector</B></A></TD><TD><BR> </TD></TR> </TABLE> <A NAME="DOC.DOCU"></A> <BLOCKQUOTE> 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. <P>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. <P>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. <P>Access through () and [] are guaranteed to be as fast as standard C arrays (assuming a resonable optimizing compiler). <P><programlisting> EST_FVector x(10); int i; <P>for (i=0; i < x.length(); ++i) x[i] = sqrt((float)i); <P>x.resize(20); <P>for (i=10; i < x.length(); ++i) x[i] = sqrt((float)i); <P></programlisting> <P>To instantialte a template for a a vector of type {FooBar} <P><programlisting> <TT>include "../base_class/EST_TVector.cc"</TT>// If you want List to vector convertion (and defined a TList) <TT>include "../base_class/EST_Tvectlist.cc"</TT> template class EST_TVector<FooBar>; template ostream& operator << (ostream &st, const EST_TVector<FooBar> &v); </programlisting> <P>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. <P></BLOCKQUOTE> <DL><DT><DT><B>See Also:</B><DD>matrix_example <BR><DD></DL><P><P><I><A HREF="index.html">Alphabetic index</A></I> <I><A HREF="HIER.html">Hierarchy of classes</A></I></P><HR> <A HREF = "http://www.ed.ac.uk/"> <IMG align=right BORDER=0 SRC = "edcrest.gif"></A> <P Align=left><I>This page is part of the <A HREF="http://www.cstr.ed.ac.uk/projects/speech_tools.html"> Edinburgh Speech Tools Library</A> documentation <br> Copyright <A HREF="http://www.ed.ac.uk"> University of Edinburgh</A> 1997 <br> Contact: <A HREF="mailto:speech_toolss@cstr.ed.ac.uk"> speech_tools@cstr.ed.ac.uk </a> </P> <br clear=right>