Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
qprimefornumbits_p.h
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#ifndef QPRIMEFORNUMBITS_P_H
5
#define QPRIMEFORNUMBITS_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <private/qtqmlglobal_p.h>
19
20
QT_BEGIN_NAMESPACE
21
22
/*
23
The prime_deltas array is a table of selected prime values, even
24
though it doesn't look like one. The primes we are using are 1,
25
2, 5, 11, 17, 37, 67, 131, 257, ..., i.e. primes in the immediate
26
surrounding of a power of two.
27
28
The qPrimeForNumBits() function returns the prime associated to a
29
power of two. For example, qPrimeForNumBits(8) returns 257.
30
*/
31
32
inline
int
qPrimeForNumBits
(
int
numBits)
33
{
34
static
constexpr
const
uchar
prime_deltas
[] = {
35
0, 0, 1, 3, 1, 5, 3, 3, 1, 9, 7, 5, 3, 9, 25, 3,
36
1, 21, 3, 21, 7, 15, 9, 5, 3, 29, 15, 0, 0, 0, 0, 0
37
};
38
39
return
(1 << numBits) +
prime_deltas
[numBits];
40
}
41
42
QT_END_NAMESPACE
43
44
#endif
// QPRIMEFORNUMBITS_P_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
qPrimeForNumBits
QT_BEGIN_NAMESPACE int qPrimeForNumBits(int numBits)
Definition
qprimefornumbits_p.h:32
prime_deltas
static const uchar prime_deltas[]
Definition
qtriangulator.cpp:408
uchar
unsigned char uchar
Definition
qtypes.h:27
qtdeclarative
src
qml
qml
ftw
qprimefornumbits_p.h
Generated by
1.9.7