Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
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
32inline 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
43
44#endif // QPRIMEFORNUMBITS_P_H
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE int qPrimeForNumBits(int numBits)
static const uchar prime_deltas[]
unsigned char uchar
Definition qtypes.h:32