Commit 405cb61e authored by Mathieu Valois's avatar Mathieu Valois
Browse files

Use modern for loops

parent a8f5a746
Loading
Loading
Loading
Loading
+6 −13
Original line number Diff line number Diff line
@@ -26,24 +26,17 @@ inline float percentage(const float& num, const float& den){
	return 100 * num / den;
}

template<typename K, typename V>
using UnorderedMapIterator = typename std::unordered_map<K, V>::const_iterator;


template<typename K, typename V>
using MapIterator = typename std::map<K, V>::const_iterator;

/**
 * @brief Order an unoredered map whatever the key's type
 * @param src: unoredered map than needed to be ordered
 * @return ordered map
 */
template<typename A>
std::multimap<uint64_t, A, std::greater<uint64_t>> flip_map(const std::unordered_map<A, uint64_t> & src) {
	std::multimap<uint64_t, A, std::greater<uint64_t>> dst;

	for(UnorderedMapIterator<A, uint64_t> it = src.begin(); it != src.end(); ++it)
		dst.insert(std::make_pair(it->second, it->first));
template<typename A, typename B>
std::multimap<B, A, std::greater<B>> flip_map(const std::unordered_map<A, B>& src){
	std::multimap<B, A, std::greater<B>> dst;
	for(std::pair<A, B> it : src){
		dst.insert(std::make_pair(it.second, it.first));
	}

	return dst;
}
+0 −1
Original line number Diff line number Diff line
@@ -222,7 +222,6 @@ double MainWindow::initGraphicalStats(QBarSeries * barLength, QPieSeries * pieCh
    uint64_t nbHideA = 0;
    pieAdvanced->clear();

    MapIterator<uint64_t, string> itA;
    for(pair<uint64_t, string> itA : reverseA) {
        top_advanced++;
        if (top_advanced <= display_advanced) {