Skip to content
Snippets Groups Projects
Select Git revision
  • ef75ece7826242b192ca96b9d74b611408ad7e41
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

mwis.hpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    mwis.hpp 36.79 KiB
    #include "search.hpp"
    
    #include <boost/heap/fibonacci_heap.hpp>
    
    #include <boost/graph/random.hpp>
    #include <boost/graph/graph_traits.hpp>
    #include <boost/graph/properties.hpp>
    #include <boost/graph/graph_concepts.hpp>
    #include <boost/graph/adjacency_list.hpp>
    
    #include <vector>
    #include <functional>
    #include <limits>
    #include <numeric>
    #include <algorithm>
    #include <iostream>
    
    namespace mwis {
    
    /**
     * A function object which compares two elements by looking up the values
     * associated to them in a property map, and comparing these using Comparator
     * (by default, using operator <).
     */
    template<typename PropertyMap,
             typename Comparator = std::less<
               typename boost::property_traits<PropertyMap>::value_type> >
    class compare_by_property {
      PropertyMap _map;
      Comparator _comparator;
    public:
      typedef typename boost::property_traits<PropertyMap>::key_type argument_type;
      typedef argument_type first_argument_type;
      typedef argument_type second_argument_type;
      typedef bool result_type;
    
      compare_by_property(PropertyMap map,
                          Comparator comparator = Comparator()):
        _map(map), _comparator(comparator)  {}
    
      bool operator()(const argument_type &a, const argument_type &b) const {
        return _comparator(get(_map, a), get(_map, b));
      }
    };
    
    /**
     * Convenience function to create a property map comparator.
     */
    template<typename PropertyMap,
             typename Comparator = std::less<
               typename boost::property_traits<PropertyMap>::value_type> >
    compare_by_property<PropertyMap, Comparator>
    make_property_map_comparator(PropertyMap map,
                                 Comparator comparator = Comparator()) {
      return compare_by_property<PropertyMap, Comparator>(map, comparator);
    }
    
    /**
     * Function object that returns true iff an element belongs to a container.
     *
     * Elements are searched by ussing the find method on the container.
     */
    template<typename Container, typename Key>
    class container_membership_test {
      const Container &_container;
    public:
      container_membership_test(const Container &container):
        _container(container)
        {}