Welcome to mirror list, hosted at ThFree Co, Russian Federation.

drawing_rule_def.cpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 197d7e1ee4b39190b3c6a0409e0b88496ca27478 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "indexer/drawing_rule_def.hpp"

#include "std/iterator.hpp"
#include "std/algorithm.hpp"


namespace drule
{
  namespace
  {
    struct less_key
    {
      bool operator() (drule::Key const & r1, drule::Key const & r2) const
      {
        // assume that unique algo leaves the first element (with max priority), others - go away
        if (r1.m_type == r2.m_type)
          return (r1.m_priority > r2.m_priority);
        else
          return (r1.m_type < r2.m_type);
      }
    };

    struct equal_key
    {
      bool operator() (drule::Key const & r1, drule::Key const & r2) const
      {
        // many line rules - is ok, other rules - one is enough
        if (r1.m_type == drule::line)
          return (r1 == r2);
        else
          return (r1.m_type == r2.m_type);
      }
    };
  }

  void MakeUnique(KeysT & keys)
  {
    sort(keys.begin(), keys.end(), less_key());
    keys.resize(distance(keys.begin(), unique(keys.begin(), keys.end(), equal_key())));
  }
}