| 1 | // Copyright (C) 2018 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 | #ifndef HASHSET_H |
| 4 | #define HASHSET_H |
| 5 | |
| 6 | #include <QtCore/qset.h> |
| 7 | |
| 8 | namespace WTF { |
| 9 | |
| 10 | template<typename Key> |
| 11 | class HashSet final : public QSet<Key> |
| 12 | { |
| 13 | public: |
| 14 | struct SetAddResult { |
| 15 | bool isNewEntry; |
| 16 | }; |
| 17 | SetAddResult add(const Key &k) |
| 18 | { |
| 19 | if (QSet<Key>::find(k) == QSet<Key>::constEnd()) { |
| 20 | QSet<Key>::insert(k); |
| 21 | return { true }; |
| 22 | } |
| 23 | return { false }; |
| 24 | } |
| 25 | }; |
| 26 | |
| 27 | } |
| 28 | |
| 29 | using WTF::HashSet; |
| 30 | |
| 31 | #endif |
| 32 | |