Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qv4estable_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 Crimson AS <info@crimson.no>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists purely as an
10// implementation detail. This header file may change from version to
11// version without notice, or even be removed.
12//
13// We mean it.
14//
15
16#ifndef QV4ESTABLE_P_H
17#define QV4ESTABLE_P_H
18
19#include <vector>
20#include <limits>
21
22#include <QtCore/q20vector.h>
23
24#include "qv4value_p.h"
25
26class tst_qv4estable;
27
28QT_BEGIN_NAMESPACE
29
30namespace QV4 {
31
32class Q_AUTOTEST_EXPORT ESTable
33{
34public:
35 // Can be used to observe changes in the position of the element at index pivot by registering an instance
36 // with `observeShifts`.
37 // This is used by implementations of `forEach`, for `ESTable`
38 // backed collections, to respect the correct order of iteration
39 // in the face of a `callbackFn` that mutates the collection
40 // itself.
42 static constexpr uint OUT_OF_TABLE = std::numeric_limits<uint>::max();
43
45
46 void next() {
47 pivot = pivot == OUT_OF_TABLE ? 0 : pivot + 1;
48 }
49 };
50
51public:
52 ESTable();
53 ~ESTable();
54
55 void markObjects(MarkStack *s, bool isWeakMap);
56 void clear();
57 void set(const Value &k, const Value &v);
58 bool has(const Value &k) const;
59 ReturnedValue get(const Value &k, bool *hasValue = nullptr) const;
60 bool remove(const Value &k);
61 uint size() const;
62 void iterate(uint idx, Value *k, Value *v);
63
64 void removeUnmarkedKeys();
65
73
74private:
75 friend class ::tst_qv4estable;
76
77 Value *m_keys = nullptr;
78 Value *m_values = nullptr;
79 uint m_size = 0;
80 uint m_capacity = 0;
81
83};
84
85} // namespace QV4
86
87QT_END_NAMESPACE
88
89#endif
Definition qjsvalue.h:23