Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
src_corelib_tools_qcontiguouscache.cpp
Go to the documentation of this file.
1
// Copyright (C) 2018 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
5
MyRecord
record
(
int
row
)
const
6
{
7
Q_ASSERT
(
row
>= 0 &&
row
<
count
());
8
9
while
(
row
>
cache
.lastIndex())
10
cache
.append(slowFetchRecord(
cache
.lastIndex()+1));
11
while
(
row
<
cache
.firstIndex())
12
cache
.prepend(slowFetchRecord(
cache
.firstIndex()-1));
13
14
return
cache
.at(
row
);
15
}
17
19
QContiguousCache<int>
cache
(10);
20
cache
.insert(INT_MAX, 1);
// cache contains one value and has valid indexes, INT_MAX to INT_MAX
21
cache
.append(2);
// cache contains two values but does not have valid indexes.
22
cache
.normalizeIndexes();
// cache has two values, 1 and 2. New first index will be in the range of 0 to capacity().
QContiguousCache
\inmodule QtCore
Definition
qcontiguouscache.h:45
count
GLenum GLenum GLsizei count
Definition
qopengles2ext.h:150
row
GLenum GLenum GLsizei void * row
Definition
qopenglext.h:2747
Q_ASSERT
#define Q_ASSERT(cond)
Definition
qrandom.cpp:47
record
MyRecord record(int row) const
[0]
Definition
src_corelib_tools_qcontiguouscache.cpp:5
cache
QContiguousCache< int > cache(10)
[0]
qtbase
src
corelib
doc
snippets
code
src_corelib_tools_qcontiguouscache.cpp
Generated by
1.9.7