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

cell_value_pair.hpp « indexer - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5533ab1706f02402e0574eb992a0fcab39bf05f7 (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
42
43
44
45
#pragma once

#include "base/macros.hpp"

#include <cstdint>

namespace covering
{
template <typename Value>
class CellValuePair
{
public:
  using ValueType = Value;

  CellValuePair() = default;

  CellValuePair(uint64_t cell, Value value)
    : m_cellLo(UINT64_LO(cell)), m_cellHi(UINT64_HI(cell)), m_value(value)
  {
  }

  bool operator<(CellValuePair const & rhs) const
  {
    if (m_cellHi != rhs.m_cellHi)
      return m_cellHi < rhs.m_cellHi;
    if (m_cellLo != rhs.m_cellLo)
      return m_cellLo < rhs.m_cellLo;
    return m_value < rhs.m_value;
  }

  uint64_t GetCell() const { return UINT64_FROM_UINT32(m_cellHi, m_cellLo); }
  Value GetValue() const { return m_value; }

private:
  uint32_t m_cellLo = 0;
  uint32_t m_cellHi = 0;
  Value m_value = 0;
};

// For backward compatibility.
static_assert(sizeof(CellValuePair<uint32_t>) == 12, "");
#ifndef OMIM_OS_LINUX
static_assert(std::is_trivially_copyable<CellValuePair<uint32_t>>::value, "");
#endif
}  // namespace covering