예제 #1
0
파일: sorted.hpp 프로젝트: LuisBL/pythran
 types::list<
     typename std::remove_cv<typename Iterable::iterator::value_type>::type>
 sorted(Iterable const &seq, C const &cmp)
 {
   types::list<typename std::remove_cv<
       typename Iterable::iterator::value_type>::type> out(seq.begin(),
                                                           seq.end());
   std::sort(out.begin(), out.end(), cmp);
   return out;
 }
예제 #2
0
inline std::string join(const std::string& separator, const Iterable& i)
{
  std::string result;
  typename Iterable::const_iterator iterator = i.begin();
  while (iterator != i.end()) {
    result += stringify(*iterator);
    if (++iterator != i.end()) {
      result += separator;
    }
  }
  return result;
}
예제 #3
0
파일: util.hpp 프로젝트: dgimb89/libzeug
std::string join(const Iterable & iterable, const std::string & separator)
{
    std::stringstream stream;

    for (auto it = iterable.begin(); it != iterable.end(); ++it)
    {
        stream << *it;

        if (it != --iterable.end())
            stream << separator;
    }

    return stream.str();
}
    GraphUsingAdjacencyMatrix::Iterable GraphUsingAdjacencyMatrix::adjacent(int v) const {
        /* A IMPLEMENTER 
         * 
         * Pour chaque sommet i, on regarde si il est adjacent à v 
         * et on l'ajoute dans l'itérateur retourné
         */
        Iterable it;

        for (int i = 0; i < V(); i++) {
            if (adjMatrix.at(v).at(i)) {
                it.push_back(i);
            }
        }

        return it;
    }
예제 #5
0
/// Check if 0 or more values are equal.
///
/// \param state   Lua state
/// \param indices Indices of values to compare
template <typename Iterable> inline
bool equal(State* state, const Iterable& indices) {
	auto it = indices.begin();
	auto end = indices.end();

	if (it == end)
		return true;

	int cmp_index = *it++;

	while (it != end) {
		int index = *it++;

		if (!equal(state, cmp_index, index))
			return false;

		cmp_index = index;
	}

	return true;
}
예제 #6
0
 long len_set(Iterable const &s)
 {
   return std::set<typename std::iterator_traits<
       typename Iterable::iterator>::value_type>(s.begin(), s.end()).size();
 }