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
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
5MyRecord 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
19QContiguousCache<int> cache(10);
20cache.insert(INT_MAX, 1); // cache contains one value and has valid indexes, INT_MAX to INT_MAX
21cache.append(2); // cache contains two values but does not have valid indexes.
22cache.normalizeIndexes(); // cache has two values, 1 and 2. New first index will be in the range of 0 to capacity().
GLenum GLenum GLsizei count
GLenum GLenum GLsizei void * row
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
MyRecord record(int row) const
[0]
QContiguousCache< int > cache(10)
[0]