Boost logo

Boost Users :

From: chun ping wang (cablepuff_at_[hidden])
Date: 2007-12-02 04:00:00


Hi, lets say i have two arbitary container of any stl type.

template
<
class T,
template <typename ELEM, typename = std::allocator<ELEM> >
class CONT
>
typename boost::enable_if<boost::is_floating_point<T>, T>::type
getManhattanDistance(const CONT<T>& ObjectX, const CONT<T>& ObjectY)

I want to be able to iterate through both containers to get the euclidean
distance.. i.e.

sqrt of sum of each item in ObjectX - ObjectY square.

Psuedocode looks like this..
/***********************************************
* getManhattanDistance(ObjectX, ObjectY) *
* overAllSum <-- 0 *
* for i <-- 0 to sizeof (ObjectX) *
* Xn <-- ObjectX[i] *
* Yn <-- ObjectY[i] *
* difference <-- (Xn - Yn) * -1 *
* overAllSum <-- overAllSum + difference *
***********************************************/

but i want to make it as abstract (allowing nonindexable containers) but
also clear as possible without losing speed. Whats the best way to do this
using boost library.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net