|
latest version v1.9 - last update 24 Nov 2005 |
|
#include <ltiSequence.h>
Inheritance diagram for lti::sequence< T >:


Public Types | |
| typedef std::vector< T >::iterator | iterator |
| typedef std::vector< T >::const_iterator | const_iterator |
Public Member Functions | |
| sequence () | |
| sequence (const int &theSize) | |
| sequence (const sequence< T > &other) | |
| virtual | ~sequence () |
| const char * | getTypeName () const |
| virtual int | size () const |
| virtual int | firstIdx () const |
| virtual const_iterator | begin () const |
| virtual iterator | begin () |
| virtual int | lastIdx () const |
| virtual const_iterator | end () const |
| virtual iterator | end () |
| virtual void | append (const T &theElement=T()) |
| virtual void | resize (const int &newSize, const T &iniValue=T(), const bool ©Data=true, const bool &initNew=true) |
| virtual void | fill (const T &iniValue, const int &from=0, const int &to=MaxInt32) |
| virtual void | fill (const sequence< T > &vct, const int &from=0, const int &to=MaxInt32, const int &startAt=0) |
| virtual T & | at (const int &x) |
| virtual const T & | at (const int &x) const |
| virtual T & | operator[] (const int &x) |
| virtual const T & | operator[] (const int &x) const |
| virtual sequence< T > & | copy (const sequence< T > &other) |
| virtual object * | clone () const |
| virtual bool | equals (const sequence< T > &other) const |
| virtual bool | operator== (const sequence< T > &other) const |
| virtual sequence< T > & | operator= (const sequence< T > &other) |
| virtual sequence< T > & | concatenate (const sequence< T > &other) |
| virtual bool | write (ioHandler &handler, const bool complete=true) const |
| virtual bool | read (ioHandler &handler, const bool complete=true) |
Protected Attributes | |
| std::vector< T > | theSequence |
The ltisequence class allows the representation of sequences of other lti objects. It can be used as a sort of vector of other objects.
The elements of the sequence will be indexed between 0 an n-1.
An example of a sequence of lti::vectors:
// creates a sequence of 256 vectors lti::sequence< lti::vector<float> > mySeq(256)
To access the vector elements use the access operators at() (or the overloaded operator[]()). For example:
for (int i = 0; i < mySeq.size(); i++) { // each element of the sequence is a vector filled with i/2 mySeq.at(i).resize(10,float(i)/2.0f); }
The sequence has following methods:
|
|||||
|
const iterator type (allows read-only operations) The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See lti::sequence::begin() for an example. |
|
|||||
|
iterator type (allows read and write operations) The use of the iterator classes is similar to the iterators of the STL (Standard Template Library). See lti::sequence::begin() for an example |
|
|||||||||
|
default constructor creates an empty sequence;
|
|
||||||||||
|
create a sequence of the given size. The member will not be initialized
|
|
||||||||||
|
create this sequence as a copy of another sequence
|
|
|||||||||
|
destructor
|
|
||||||||||
|
append element to sequence.
resize() |
|
||||||||||
|
access element x of the sequence in a read-only modus
|
|
||||||||||
|
access element x of the sequence
|
|
|||||||||
|
returns an iterator pointing to the first element of the sequence The use of the interators is similar to the iterators of the Standard Template Library (STL). If you need to iterate on all elements of the sequence, you can use following code: int accu = 1; lti::sequence<vector<int> > mySeq(10); // a sequence with 10 elements lti::sequence<vector<int> >::iterator it; // an iterator for (it=mySeq.begin();it!=mySeq.end();it++) { vector<int>& tmp = *it; // tmp is a reference to the vector // pointed by the iterator. accu++; tmp.resize(accu,accu); // resize and initialize the vector } |
|
|||||||||
|
returns first element as a const_iterator. Note that you can not change the values of the sequence elements when you use a const_iterator. See also begin() |
|
|||||||||
|
create a clone of this sequence
|
|
||||||||||
|
concatenate another sequence to this one the elements of the other sequence will be concatenated
|
|
||||||||||
|
assigment operator.
copy the contents of
|
|
|||||||||
|
returns last index as an iterator For an example see begin()
|
|
|||||||||
|
returns last index as a const iterator. For an example see begin() |
|
||||||||||
|
compare this sequence with other
|
|
||||||||||||||||||||||||
|
fills the sequence elements from
|
|
||||||||||||||||||||
|
fills the sequence elements with
from or to are out of bounds, they will be (internaly) adjusted to to correct value.Example: lti::sequence<double> myVct(10,0); // sequence with 10 elements // with 0 myVct.fill(9,1,3); // myVct=[0,9,9,9,0,0,0,0,0,0] |
|
|||||||||
|
returns first index (normally 0)
|
|
||||||||||
|
returns the name of this class: "sequence"
Reimplemented from lti::ioObject. |
|
|||||||||
|
returns last index (in a sequence this is always size()-1)
|
|
||||||||||
|
assigment operator (alias for copy(other)).
|
|
||||||||||
|
compare this sequence with other
|
|
||||||||||
|
const access operator (alias for at(const int& x) const).
|
|
||||||||||
|
access operator (alias for at(const int& x)).
|
|
||||||||||||||||
|
read the sequence from the given ioHandler
Reimplemented from lti::ioObject. |
|
||||||||||||||||||||||||
|
change dimension of the sequence.
lti::sequence<int> myVct; // creates empty sequence myVct.resize(5,0); // sequence with 5 elements initialized // with 0 myVct.resize(10,2); // sequence has now 10 elements: the // first five are still 0 and the // rest have a 2 myVct.resize(20,3,false,false); // now the sequence has 20 // elements but their values // are unknown. myVct.resize(5,1,false,true); // the sequence has now 5 // elements initialized with 1 // note that the last line could also be written: myVct.resize(5,1,false); // the sequence has now 5 // elements initialized with 1 If the resize is possible (see useExternData()), this object will always owns the data! |
|
|||||||||
|
returns the number of elements of the sequence
|
|
||||||||||||||||
|
write the sequence in the given ioHandler
Reimplemented from lti::ioObject. |
|
|||||
|
this sequence class is implemented with a std::vector instance
|