/*! \file mapper.h * \brief map values (prototypes) * * ---------------------------------------------------------------------------- * * $Id: mapper.h,v 1.5 2005-04-28 15:01:47 tforb Exp $ * \author Thomas Forbriger * \date 20/03/2005 * * map values (prototypes) * * Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach) * * REVISIONS and CHANGES * - 20/03/2005 V1.0 Thomas Forbriger * * ============================================================================ */ // include guard #ifndef AFF_MAPPER_H_VERSION #define AFF_MAPPER_H_VERSION \ "AFF_MAPPER_H V1.0 " #define AFF_MAPPER_H_CVSID \ "$Id: mapper.h,v 1.5 2005-04-28 15:01:47 tforb Exp $" #include namespace aff { namespace func { namespace util { /*! Function template to map values from one container to another * * This is a framework to browse through a container and map * values to values of a different type. This function template is used * by container functions like aff::func::valmap(). * * \param C any container class like aff::Array * \param F any mapper utility class like * aff::func::util::Mapvalmap * * \param c container to read values to be mapped * \param exfun fully initialized mapper utility * \return result container of same shape as c but with mapped values * * \sa aff::func::valmap() */ template class C, class F> C mapvalues(const typename C::Tcoc& c, const F& exfun) { typedef typename C::Tcoc Tin; typedef C Tout; Tout retval(c.shape()); aff::Browser browser(c); aff::Iterator iterator(retval); while(browser.valid() && iterator.valid()) { *iterator = exfun(*browser); ++browser; ++iterator; } return(retval); }; // mapvalues } // namespace util } // namespace func } // namespace aff #endif // AFF_MAPPER_H_VERSION (includeguard) /* ----- END OF mapper.h ----- */