1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef SPATIAL_INDEX_ENTRY_P_H
8#define SPATIAL_INDEX_ENTRY_P_H
9
10#include <cstdint>
11
12#pragma pack(push)
13#pragma pack(1)
14
15/** Entry in the spatial index.
16 * This is essentially just a pair of numbers, the first being the position
17 * on the z-order curve and defines the order, the second being the index into the
18 * property table.
19 *
20 * These entries exist in very large quantities, so compact storage is important.
21 */
22class SpatialIndexEntry
23{
24public:
25 inline constexpr SpatialIndexEntry(uint32_t z, uint32_t propertyIdx)
26 : m_z(z)
27 , m_unused(0)
28 , m_propHigh(propertyIdx >> 8)
29 , m_propLow(propertyIdx)
30 {
31 }
32
33 inline constexpr uint32_t z() const
34 {
35 return m_z;
36 }
37
38 inline constexpr uint32_t propertyIndex() const
39 {
40 return m_propHigh << 8 | m_propLow;
41 }
42
43private:
44 uint32_t m_z : 22;
45 [[maybe_unused]] uint32_t m_unused : 6;
46 uint32_t m_propHigh : 4;
47 uint8_t m_propLow;
48};
49
50#pragma pack(pop)
51
52inline constexpr bool operator<(SpatialIndexEntry lhs, SpatialIndexEntry rhs)
53{
54 return lhs.z() < rhs.z();
55}
56
57inline constexpr bool operator<(SpatialIndexEntry lhs, uint32_t rhs)
58{
59 return lhs.z() < rhs;
60}
61
62inline constexpr bool operator<(uint32_t lhs, SpatialIndexEntry rhs)
63{
64 return lhs < rhs.z();
65}
66
67#endif
68

source code of ki18n/src/localedata/spatial_index_entry_p.h