7#include <QtCore/qhash.h>
12template <
class Key,
class T>
19 Value()
noexcept =
default;
23 Value(Value &&
other) noexcept
29 Value &operator=(Value &&
other)
noexcept
32 std::swap(cost,
other.cost);
35 ~Value() {
delete t; }
43 Chain() noexcept : prev(
this),
next(
this) { }
48 struct Node :
public Chain
51 using ValueType = Value;
56 Node(
const Key &k, Value &&
t)
noexcept(std::is_nothrow_move_assignable_v<Key>)
62 Node(
Key &&k, Value &&
t)
noexcept(std::is_nothrow_move_assignable_v<Key>)
84 this->prev->next =
this;
85 this->
next->prev =
this;
98 void unlink(Node *
n)
noexcept(std::is_nothrow_destructible_v<Node>)
102 n->prev->next =
n->next;
103 n->next->prev =
n->prev;
104 total -=
n->value.cost;
105 auto it =
d.findBucket(
n->key);
108 T *relink(
const Key &
key)
const noexcept
112 Node *
n =
d.findNode(
key);
116 if (chain.next !=
n) {
119 n->prev->next =
n->next;
120 n->next->prev =
n->prev;
121 n->next = chain.next;
122 chain.next->prev =
n;
129 void trim(
qsizetype m)
noexcept(std::is_nothrow_destructible_v<Node>)
131 while (chain.prev != &chain && total >
m) {
132 Node *
n =
static_cast<Node *
>(chain.prev);
147 static_assert(std::is_nothrow_destructible_v<Key>,
"Types with throwing destructors are not supported in Qt containers.");
148 static_assert(std::is_nothrow_destructible_v<T>,
"Types with throwing destructors are not supported in Qt containers.");
163 inline bool isEmpty() const noexcept {
return !
d.size; }
169 for (
auto it =
d.begin();
it !=
d.end(); ++
it)
176 void clear() noexcept(
std::is_nothrow_destructible_v<Node>)
195 auto prevCost =
n->value.cost;
200 Node::createInPlace(
n,
key,
object,
cost);
202 n->next = chain.next;
203 chain.next->prev =
n;
222 bool remove(
const Key &
key)
noexcept(std::is_nothrow_destructible_v<Node>)
226 Node *
n =
d.findNode(
key);
235 T *
take(
const Key &
key)
noexcept(std::is_nothrow_destructible_v<Key>)
239 Node *
n =
d.findNode(
key);
244 n->value.t =
nullptr;
T * operator[](const Key &key) const noexcept
bool remove(const Key &key) noexcept(std::is_nothrow_destructible_v< Node >)
void setMaxCost(qsizetype m) noexcept(std::is_nothrow_destructible_v< Node >)
bool contains(const Key &key) const noexcept
qsizetype count() const noexcept
QCache(qsizetype maxCost=100) noexcept
T * object(const Key &key) const noexcept
qsizetype maxCost() const noexcept
qsizetype totalCost() const noexcept
qsizetype size() const noexcept
void clear() noexcept(std::is_nothrow_destructible_v< Node >)
T * take(const Key &key) noexcept(std::is_nothrow_destructible_v< Key >)
bool insert(const Key &key, T *object, qsizetype cost=1)
bool isEmpty() const noexcept
QList< Key > keys() const
qsizetype size() const noexcept
void reserve(qsizetype size)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum GLuint GLintptr GLsizeiptr size
[1]
static qsizetype cost(const QPixmap &pixmap)
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept