Revision cb770240 custompackages/graph-parser/src/utility.h

View differences:

custompackages/graph-parser/src/utility.h
1 1
//
2 2
// Created by quynh on 12/15/15.
3
// All the generic functions are defined in utility.tpp - 27/01/2015
3 4
//
4 5

  
5 6
#ifndef GRAPH_PARSER_UTILITY_H
......
19 20
namespace outops {
20 21
    std::ostream& operator<<(std::ostream& os, const Graph& g);
21 22

  
22
    template <typename T>
23
    // I have to use pair to add more than one argument for cout operator<<
24
    std::ostream& operator<<(std::ostream& os, std::pair<const Graph&, const VertexIndexMap&> p);
25

  
26
    template <typename T> // declared in utitlity.tpp
23 27
    std::ostream& operator<<(std::ostream& os, const std::set<T>& s);
28

  
29
    std::ostream& operator<<(std::ostream& os, const std::map<string, int>& m);
30

  
31
    std::ostream& operator<<(std::ostream& os, const vector< vector< int> >& data);
24 32
}
25 33

  
34
namespace printhelper {
35
    template <typename T1, typename T2> void for_map(const std::map<T1, T2> m);
36
}
26 37
// non-member functions operating on Graph datatype.
27 38
namespace graphext {
28
    void id_of_vertices(const Graph& g, std::set<std::string>& r);
39
    void id_of_all_vertices(const Graph& g, std::set<std::string>& r);
29 40

  
30 41
    template <typename Container>
31
    void id_of_vertices(const Graph& g, const Container& container, std::set<std::string>& r);
42
    void id_of_some_vertices(const Graph& g, const Container& container, std::set<std::string>& r);
43

  
44
    void print_v_index_std_map(const Graph& g, const VertexIndexStdMap& v_index_std_map);
45
    void print_v_index_map(const Graph& g, const VertexIndexMap& v_index_map);
32 46
}
33 47

  
48
namespace setops {
49
    template <typename T> std::set<T> operator-(const std::set<T>& a, const std::set<T>& b);
50
    template <typename T> std::set<T> operator/(const std::set<T>& a, const std::set<T>& b);
51
}
52

  
53
namespace stdhelper {
54
    template <typename T1, typename T2> bool exists(const std::map<T1, T2>& m, const T1& key);
55
    template <typename T> bool exists(const std::set<T>& s, const T& element);
56
}
57

  
58
template <typename Pair>
59
struct second_equal_to
60
    : std::unary_function<const Pair&, bool>
61
{
62
    second_equal_to(const typename Pair::second_type& value)
63
        : value_(value) { }
64

  
65
    bool operator()(const Pair& p) const
66
    {
67
        return p.second == value_;
68
    }
34 69

  
70
private:
71
    typename Pair::second_type value_;
72
};
35 73

  
36 74
#include "utility.tpp"
37 75

  

Also available in: Unified diff