/* * Main authors: * Grégoire Dooms * * Copyright: * Grégoire Dooms (Université catholique de Louvain), 2005 * * Last modified: * $Date: 2005-11-29 21:15:36 +0100 (Tue, 29 Nov 2005) $ * $Revision: 280 $ * * This file is part of CP(Graph) * * See the file "contribs/graph/LICENSE" for information on usage and * redistribution of this file, and for a * DISCLAIMER OF ALL WARRANTIES. * */ #ifndef STLUTILITY_ICC #define STLUTILITY_ICC #include #include #include /// outputs a vector template std::ostream& operator<<(std::ostream& os, const std::vector &v){ os << "["; for (typename std::vector::const_iterator i=v.begin(); i!=v.end(); ++i){ if (i!=v.begin()) { os <<", "; } os << *i; } os << "]"; return os; } /// outputs a std::pair template std::ostream& operator<<(std::ostream& os, const std::pair &p){ os << "(" << p->first << ", " << p->second << ")"; return os; } /// outputs a std::list of template std::ostream& operator<<(std::ostream& os, std::list &l){ os << "["; for (typename std::list::const_iterator i=l.begin(); i!=l.end(); ++i){ if (i!=l.begin()) { os <<", "; } os << *i; } os << "]"; return os; } //TODO check we can get rid of this one /// outputs a std::list of std::pair template std::ostream& operator<<(std::ostream& os, std::list > &l){ os << "["; for (typename std::list >::const_iterator i=l.begin(); i!=l.end(); ++i){ if (i!=l.begin()) { os <<", "; } os << "(" << i->first << ", " << i->second << ")"; } os << "]"; return os; } namespace Gecode { namespace Graph { /** find the minimum val from a container in between two iterators */ template typename std::iterator_traits::value_type minimum(iterator begin, iterator end){ typedef typename std::iterator_traits::value_type T; struct fmin : public std::unary_function{ T min; fmin(T init): min(init){} void operator() (T x) { if (x iterator minimum_index(iterator begin, iterator end){ typedef typename std::iterator_traits::value_type T; if (begin==end) return end; T min = *begin; iterator min_index = begin; for (iterator cur = begin; cur!=end; ++cur){ if (*cur