File: sortedset.h

package info (click to toggle)
sqlitestudio 3.4.21%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 54,880 kB
  • sloc: ansic: 406,208; cpp: 123,872; yacc: 2,692; tcl: 497; sh: 462; xml: 426; makefile: 19
file content (64 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef SORTEDSET_H
#define SORTEDSET_H

#include "common/sortedhash.h"

template <class T>
class SortedSet : private SortedHash<T, bool>
{
    public:
        bool contains(const T &value) const
        {
            return QHash<T, bool>::containsKey(value);
        }

        int	count() const
        {
            return size();
        }

        bool isEmpty() const
        {
            return SortedHash<T, bool>::isEmpty();
        }

        bool remove(const T& value)
        {
            return SortedHash<T, bool>::remove(value);
        }

        int	size() const
        {
            return QHash<T, bool>::size();
        }

        void swap(SortedSet<T>& other)
        {
            return SortedHash<T, bool>::swap(other);
        }

        SortedSet<T>& operator+=(const T& value)
        {
            SortedHash<T, bool>::insert(value, true);
            return *this;
        }

        SortedSet<T>& operator-=(const T& value)
        {
            SortedHash<T, bool>::remove(value);
            return *this;
        }

        QSet<T>& operator<<(const T &value)
        {
            SortedHash<T, bool>::insert(value, true);
            return *this;
        }

        QList<T> toList()
        {
            return SortedHash<T, bool>::keys();
        }
};

#endif // SORTEDSET_H