latest version v1.9 - last update 10 Apr 2010 |
tpointList template class. More...
#include <ltiPointList.h>
Public Types | |
typedef list_type::iterator | iterator |
typedef list_type::const_iterator | const_iterator |
typedef list_type::reference | reference |
typedef list_type::const_reference | const_reference |
Public Member Functions | |
tpointList () | |
tpointList (const tpointList< T > &other) | |
tpointList (const list_type &other) | |
virtual | ~tpointList () |
const char * | getTypeName () const |
int | size () const |
bool | operator< (const tpointList< T > &other) const |
bool | operator> (const tpointList< T > &other) const |
const_iterator | begin () const |
iterator | begin () |
const_iterator | end () const |
iterator | end () |
void | clear () |
iterator | erase (const iterator &it) |
iterator | erase (const iterator &first, const iterator &last) |
iterator | insert (const iterator &it, const tpoint< T > &thePoint) |
iterator | insert (const iterator &it, const int &n, const tpoint< T > &thePoint) |
iterator | insert (const iterator &it, const_iterator first, const_iterator last) |
void | splice (const iterator &pos, tpointList< T > &other) |
void | push_front (const tpoint< T > &thePoint) |
void | pop_front () |
void | push_back (const tpoint< T > &thePoint) |
void | pop_back () |
reference | front () |
const_reference | front () const |
reference | back () |
const_reference | back () const |
tpointList< T > & | copy (const tpointList< T > &other) |
tpointList< T > & | operator= (const tpointList< T > &other) |
virtual object * | clone () const |
bool | equals (const tpointList< T > &other) const |
bool | operator== (const tpointList< T > &other) const |
bool | empty () const |
void | sort () |
template<class Compare > | |
void | sort (Compare func) |
const trectangle< T > & | getBoundary () const |
void | setBoundary (const trectangle< T > &r) |
const trectangle< T > | computeBoundary () const |
const trectangle< T > & | updateBoundary () |
virtual bool | write (ioHandler &handler, const bool complete=true) const |
virtual bool | read (ioHandler &handler, const bool complete=true) |
Conversion Methods | |
tpointList< T > & | castFrom (const list_type &other) |
template<class U > | |
tpointList< T > & | castFrom (const tpointList< U > &other) |
template<class U > | |
tpointList< T > & | castFrom (const vector< tpoint< U > > &other) |
template<class U > | |
tpointList< T > & | castFrom (const vector< tpoint< U > > &other) const |
template<class U > | |
void | castTo (vector< tpoint< U > > &other) const |
Protected Attributes | |
list_type | thePointList |
trectangle< T > | boundary |
tpointList template class.
The ltitpointList class allows the storage of a list of tpoints<T>. The elements of the tpointList can be accessed through iterators.
Example:
lti::pointList pts; // a list of points with integer coodinates // create 10 points for (int i=0;i<10;++i) { pts.push_back(point(i,i)); } // iterate on the list of points to add 1 to x and 2 to y: lti::pointList::iterator it; for (it=pts.begin();it!=pts.end();++pts) { (*pts).add(point(1,2)); }
typedef list_type::const_iterator lti::tpointList< T >::const_iterator |
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::pointList::begin() for an example.
typedef list_type::const_reference lti::tpointList< T >::const_reference |
const_reference type (allows read-only operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).
typedef list_type::iterator lti::tpointList< T >::iterator |
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::pointList::begin() for an example
typedef list_type::reference lti::tpointList< T >::reference |
reference type (allows read and write operations) The use of the reference classes is similar to the references of the STL (Standard Template Library).
lti::tpointList< T >::tpointList | ( | ) |
default constructor creates an empty pointList;
lti::tpointList< T >::tpointList | ( | const tpointList< T > & | other | ) |
create this pointList as a copy of another pointList
other | the pointList to be copied. |
lti::tpointList< T >::tpointList | ( | const list_type & | other | ) |
create this pointList as a copy of a list_type of tpoint<T>
other | the pointList to be copied. |
virtual lti::tpointList< T >::~tpointList | ( | ) | [virtual] |
destructor
const_reference lti::tpointList< T >::back | ( | ) | const |
returns a const reference to the last element
reference lti::tpointList< T >::back | ( | ) |
returns a reference to the last element
iterator lti::tpointList< T >::begin | ( | ) |
returns an iterator pointing to the first element of the pointList 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 pointList, you can use following code:
lti::tpointList<int> myPL; // an empty pointList lti::tpointList<int>::iterator it; // an iterator // Fill pointList with some arbitrary points for (int i=0; i<10; i++) { myPL.push_back(lti::point(0,i)); } // Swap x and y for all points in list for (it=myPL.begin();it!=myPL.end();it++) { int temp; temp = (*it).x; (*it).x = (*it).y; (*it).y = temp; }
const_iterator lti::tpointList< T >::begin | ( | ) | const |
returns first element as a const_iterator.
Note that you can not change the values of the pointList elements when you use a const_iterator. See also begin()
Referenced by lti::geometricTransform::apply(), lti::tpointList< int >::castFrom(), and lti::tpointList< int >::castTo().
tpointList<T>& lti::tpointList< T >::castFrom | ( | const vector< tpoint< U > > & | other | ) | const [inline] |
tpointList<T>& lti::tpointList< T >::castFrom | ( | const vector< tpoint< U > > & | other | ) | [inline] |
tpointList<T>& lti::tpointList< T >::castFrom | ( | const tpointList< U > & | other | ) | [inline] |
copy the other
point-list by casting each of its elements
other | The point list to be casted |
tpointList<T>& lti::tpointList< T >::castFrom | ( | const list_type & | other | ) |
copy the elements of the other standard list of tpoint<T> in this object
other | the source pointList to be copied. |
void lti::tpointList< T >::castTo | ( | vector< tpoint< U > > & | other | ) | const [inline] |
cast this list of points into a lti::vector, which can be accessed in a faster way than the list.
void lti::tpointList< T >::clear | ( | ) |
deletes all points from list and leaves empty pointList.
Referenced by lti::geometricTransform::apply(), and lti::tpointList< int >::castFrom().
virtual object* lti::tpointList< T >::clone | ( | ) | const [virtual] |
create a clone of this pointList
const trectangle<T> lti::tpointList< T >::computeBoundary | ( | ) | const |
calculate the boundary box.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be calculated.
This member computes the boundary, but it does not set the compute one into the internal boundary attribute. See also updateBoundary().
tpointList<T>& lti::tpointList< T >::copy | ( | const tpointList< T > & | other | ) |
assigment operator.
copy the contents of other
in this object.
other | the source pointList to be copied. |
Reimplemented from lti::ioObject.
Referenced by lti::tpolygonPoints< int >::operator=(), lti::areaPoints::operator=(), lti::borderPoints::operator=(), and lti::ioPoints::operator=().
bool lti::tpointList< T >::empty | ( | ) | const |
returns true if the list is empty
iterator lti::tpointList< T >::end | ( | ) |
returns last element as an iterator For an example see begin()
const_iterator lti::tpointList< T >::end | ( | ) | const |
returns last element as a const iterator.
For an example see begin()
Referenced by lti::geometricTransform::apply(), and lti::tpointList< int >::castFrom().
bool lti::tpointList< T >::equals | ( | const tpointList< T > & | other | ) | const |
compare this pointList with other
other | the other pointList to be compared with |
iterator lti::tpointList< T >::erase | ( | const iterator & | first, | |
const iterator & | last | |||
) |
erases points between first and last.
Returns iterator to next element.
iterator lti::tpointList< T >::erase | ( | const iterator & | it | ) |
erases point, which is denoted by it.
Returns iterator to next element.
const_reference lti::tpointList< T >::front | ( | ) | const |
returns a const reference to the first element
reference lti::tpointList< T >::front | ( | ) |
returns a reference to the first element
const trectangle<T>& lti::tpointList< T >::getBoundary | ( | ) | const [inline] |
returns the last set or calculated boundary.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be updated (see lti::tpointList<T>::updateBoundary). It will NOT be updated automatically
const char* lti::tpointList< T >::getTypeName | ( | void | ) | const [inline, virtual] |
returns the name of this class: tpointList<T>
Reimplemented from lti::ioObject.
Reimplemented in lti::ioPoints, lti::borderPoints, lti::areaPoints, lti::tpolygonPoints< T >, and lti::tpolygonPoints< int >.
iterator lti::tpointList< T >::insert | ( | const iterator & | it, | |
const_iterator | first, | |||
const_iterator | last | |||
) |
inserts the elements from first to last, before position denoted by it.
Returns iterator to first element of inserted elements.
iterator lti::tpointList< T >::insert | ( | const iterator & | it, | |
const int & | n, | |||
const tpoint< T > & | thePoint | |||
) |
inserts points before position denoted by it.
Returns iterator to first element of inserted elements.
iterator lti::tpointList< T >::insert | ( | const iterator & | it, | |
const tpoint< T > & | thePoint | |||
) |
inserts point before position denoted by it.
returns iterator to inserted element.
bool lti::tpointList< T >::operator< | ( | const tpointList< T > & | other | ) | const |
compares the size of this list with the size of the other point list and returns true if this list has fewer points than the other one.
tpointList<T>& lti::tpointList< T >::operator= | ( | const tpointList< T > & | other | ) |
assigment operator (alias for copy(other)).
other | the pointList to be copied |
Reimplemented from lti::ioObject.
Reimplemented in lti::ioPoints, lti::borderPoints, lti::areaPoints, lti::tpolygonPoints< T >, and lti::tpolygonPoints< int >.
bool lti::tpointList< T >::operator== | ( | const tpointList< T > & | other | ) | const |
compare this pointList with other
other | the other pointList to be compared with |
bool lti::tpointList< T >::operator> | ( | const tpointList< T > & | other | ) | const |
compares the size of this list with the size of the other point list and returns true if this list has more points than the other one.
void lti::tpointList< T >::pop_back | ( | ) |
removes element at end of pointList
void lti::tpointList< T >::pop_front | ( | ) |
removes element at begin of pointList
void lti::tpointList< T >::push_back | ( | const tpoint< T > & | thePoint | ) |
inserts element at end of pointList
Referenced by lti::geometricTransform::apply(), and lti::tpointList< int >::castFrom().
void lti::tpointList< T >::push_front | ( | const tpoint< T > & | thePoint | ) |
inserts element at begin of pointList
virtual bool lti::tpointList< T >::read | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | [virtual] |
read the point list from the given ioHandler
Reimplemented from lti::ioObject.
Referenced by lti::read().
void lti::tpointList< T >::setBoundary | ( | const trectangle< T > & | r | ) | [inline] |
set the boundary of the points.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user using this method, or the user must explicitly specify that it must be updated (see lti::tpointList<T>::updateBoundary). It will NOT be updated automatically with each point you insert or delete.
int lti::tpointList< T >::size | ( | ) | const |
returns the number of elements of the pointList
Referenced by lti::tpointList< int >::castTo().
void lti::tpointList< T >::sort | ( | Compare | func | ) | [inline] |
sort the list using Compare
.
Compare
must be a struct that declares
bool operator() (const T& x, const T& y) const
or a function with the same signature (note that this function pointer approach is usually slower)
void lti::tpointList< T >::sort | ( | ) |
sort the list using std::less<T>, i.e.
Reimplemented in lti::ioPoints, and lti::areaPoints.
void lti::tpointList< T >::splice | ( | const iterator & | pos, | |
tpointList< T > & | other | |||
) |
Transfer all elements in the second list into this one.
At the end of the operation, the second list will be empty
const trectangle<T>& lti::tpointList< T >::updateBoundary | ( | ) |
calculate and update the boundary box.
The boundary is the smallest rectangle that contains all the points in the list. Note that the boundary must be set by the user, or the user must explicitly specify that it must be calculated.
This member computes the boundary AND set the internal boundary attribute. See also computeBoundary().
virtual bool lti::tpointList< T >::write | ( | ioHandler & | handler, | |
const bool | complete = true | |||
) | const [virtual] |
write the point list in the given ioHandler
Reimplemented from lti::ioObject.
Referenced by lti::write().
trectangle<T> lti::tpointList< T >::boundary [protected] |
boundary is the smallest rectangle which includes all the points in the list
Referenced by lti::tpointList< int >::getBoundary(), and lti::tpointList< int >::setBoundary().
list_type lti::tpointList< T >::thePointList [protected] |
this pointList class is implemented with a list_type<> instance