LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::tpointList< T > Class Template Reference
[Aggregate Data Types]

tpointList template class. More...

#include <ltiPointList.h>

Inheritance diagram for lti::tpointList< T >:
Inheritance graph
[legend]
Collaboration diagram for lti::tpointList< T >:
Collaboration graph
[legend]

List of all members.

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 objectclone () 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

Detailed Description

template<class T>
class lti::tpointList< T >

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));
 }

Member Typedef Documentation

template<class T>
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.

template<class T>
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).

template<class T>
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

template<class T>
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).


Constructor & Destructor Documentation

template<class T>
lti::tpointList< T >::tpointList (  ) 

default constructor creates an empty pointList;

template<class T>
lti::tpointList< T >::tpointList ( const tpointList< T > &  other  ) 

create this pointList as a copy of another pointList

Parameters:
other the pointList to be copied.
template<class T>
lti::tpointList< T >::tpointList ( const list_type &  other  ) 

create this pointList as a copy of a list_type of tpoint<T>

Parameters:
other the pointList to be copied.
template<class T>
virtual lti::tpointList< T >::~tpointList (  )  [virtual]

destructor


Member Function Documentation

template<class T>
const_reference lti::tpointList< T >::back (  )  const

returns a const reference to the last element

template<class T>
reference lti::tpointList< T >::back (  ) 

returns a reference to the last element

template<class T>
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;
 }
template<class T>
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().

template<class T>
template<class U >
tpointList<T>& lti::tpointList< T >::castFrom ( const vector< tpoint< U > > &  other  )  const [inline]

cast the given vector of points into a list, where the first element in the vector will be the first element in the list.

template<class T>
template<class U >
tpointList<T>& lti::tpointList< T >::castFrom ( const vector< tpoint< U > > &  other  )  [inline]

cast the given vector of points into a list, where the first element in the vector will be the first element in the list.

Parameters:
other the vector of points with the points
Returns:
a reference to this instance
template<class T>
template<class U >
tpointList<T>& lti::tpointList< T >::castFrom ( const tpointList< U > &  other  )  [inline]

copy the other point-list by casting each of its elements

Parameters:
other The point list to be casted
template<class T>
tpointList<T>& lti::tpointList< T >::castFrom ( const list_type &  other  ) 

copy the elements of the other standard list of tpoint<T> in this object

Parameters:
other the source pointList to be copied.
template<class T>
template<class U >
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.

template<class T>
void lti::tpointList< T >::clear (  ) 

deletes all points from list and leaves empty pointList.

Referenced by lti::geometricTransform::apply(), and lti::tpointList< int >::castFrom().

template<class T>
virtual object* lti::tpointList< T >::clone (  )  const [virtual]

create a clone of this pointList

Returns:
a pointer to a copy of this pointList
template<class T>
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().

Returns:
a the calculated boundary
template<class T>
tpointList<T>& lti::tpointList< T >::copy ( const tpointList< T > &  other  ) 

assigment operator.

copy the contents of other in this object.

Parameters:
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=().

template<class T>
bool lti::tpointList< T >::empty (  )  const

returns true if the list is empty

template<class T>
iterator lti::tpointList< T >::end (  ) 

returns last element as an iterator For an example see begin()

template<class T>
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().

template<class T>
bool lti::tpointList< T >::equals ( const tpointList< T > &  other  )  const

compare this pointList with other

Parameters:
other the other pointList to be compared with
Returns:
true if both pointLists have the same elements and same size
template<class T>
iterator lti::tpointList< T >::erase ( const iterator first,
const iterator last 
)

erases points between first and last.

Returns iterator to next element.

template<class T>
iterator lti::tpointList< T >::erase ( const iterator it  ) 

erases point, which is denoted by it.

Returns iterator to next element.

template<class T>
const_reference lti::tpointList< T >::front (  )  const

returns a const reference to the first element

template<class T>
reference lti::tpointList< T >::front (  ) 

returns a reference to the first element

template<class T>
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

template<class T>
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 >.

template<class T>
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.

template<class T>
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.

template<class T>
iterator lti::tpointList< T >::insert ( const iterator it,
const tpoint< T > &  thePoint 
)

inserts point before position denoted by it.

returns iterator to inserted element.

template<class T>
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.

template<class T>
tpointList<T>& lti::tpointList< T >::operator= ( const tpointList< T > &  other  ) 

assigment operator (alias for copy(other)).

Parameters:
other the pointList to be copied
Returns:
a reference to the actual pointList

Reimplemented from lti::ioObject.

Reimplemented in lti::ioPoints, lti::borderPoints, lti::areaPoints, lti::tpolygonPoints< T >, and lti::tpolygonPoints< int >.

template<class T>
bool lti::tpointList< T >::operator== ( const tpointList< T > &  other  )  const

compare this pointList with other

Parameters:
other the other pointList to be compared with
Returns:
true if both pointLists have the same elements and same size
template<class T>
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.

template<class T>
void lti::tpointList< T >::pop_back (  ) 

removes element at end of pointList

template<class T>
void lti::tpointList< T >::pop_front (  ) 

removes element at begin of pointList

template<class T>
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().

template<class T>
void lti::tpointList< T >::push_front ( const tpoint< T > &  thePoint  ) 

inserts element at begin of pointList

template<class T>
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().

template<class T>
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.

template<class T>
int lti::tpointList< T >::size (  )  const

returns the number of elements of the pointList

Referenced by lti::tpointList< int >::castTo().

template<class T>
template<class Compare >
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)

template<class T>
void lti::tpointList< T >::sort (  ) 

sort the list using std::less<T>, i.e.

operator<()

Reimplemented in lti::ioPoints, and lti::areaPoints.

template<class T>
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

template<class T>
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().

Returns:
a reference to the calculated boundary
template<class T>
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().


Member Data Documentation

template<class T>
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().

template<class T>
list_type lti::tpointList< T >::thePointList [protected]

this pointList class is implemented with a list_type<> instance


The documentation for this class was generated from the following file:

Generated on Sat Apr 10 15:27:40 2010 for LTI-Lib by Doxygen 1.6.1