File: item.h

package info (click to toggle)
libcds 2.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 15,564 kB
  • sloc: cpp: 135,002; ansic: 7,218; perl: 243; sh: 237; makefile: 6
file content (59 lines) | stat: -rw-r--r-- 1,507 bytes parent folder | download | duplicates (3)
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
// Copyright (c) 2006-2018 Maxim Khizhinsky
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

#ifndef CDSSTRESS_PQUEUE_ITEM_H
#define CDSSTRESS_PQUEUE_ITEM_H

namespace pqueue {

    struct simple_value {
        typedef size_t  key_type;

        key_type key;

        struct key_extractor {
            void operator()( key_type& k, simple_value const& s ) const
            {
                k = s.key;
            }
        };

        simple_value()
            : key(0)
        {}

        simple_value( key_type n )
            : key(n)
        {}

        friend bool operator <( simple_value const& lhs, simple_value const& rhs )
        {
            return lhs.key < rhs.key;
        }
        friend bool operator <( simple_value const& lhs, size_t rhs )
        {
            return lhs.key < rhs;
        }
        friend bool operator <( size_t lhs, simple_value const& rhs )
        {
            return lhs < rhs.key;
        }

        friend bool operator >( simple_value const& lhs, simple_value const& rhs )
        {
            return lhs.key > rhs.key;
        }
        friend bool operator >( simple_value const& lhs, size_t rhs )
        {
            return lhs.key > rhs;
        }
        friend bool operator >( size_t lhs, simple_value const& rhs )
        {
            return lhs > rhs.key;
        }
    };
} // namespace pqueue

#endif // #ifndef CDSSTRESS_PQUEUE_ITEM_H