File: UserTypes.h

package info (click to toggle)
libstxxl 1.3.1-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,532 kB
  • sloc: cpp: 30,003; ansic: 3,507; makefile: 665; sh: 515; perl: 289
file content (73 lines) | stat: -rw-r--r-- 1,270 bytes parent folder | download | duplicates (2)
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
65
66
67
68
69
70
71
72
73
#ifndef INCLUDE_USER_TYPES
#define INCLUDE_USER_TYPES

#include <stxxl/all>
#include <limits>

struct type1
{
    int key;
    int data[3];
    bool operator == (const type1 & a) const
    {
        return key == a.key;
    }
    type1() { }
    type1(int key_) : key(key_) { }
};
struct type2
{
    int key;
    int data[7];
    bool operator == (const type2 & a) const
    {
        return key == a.key;
    }
    type2() { }
    type2(int key_) : key(key_) { }
};

struct my_rnd
{
    stxxl::random_number32 rnd;
    int operator()  () const
    {
        return rnd() % 0xfffff;
    }
};

template <class T>
struct LessCmp
{
    bool operator ()  (const T & a, const T & b) const
    {
        return a.key < b.key;
    }
    static int min_value()
    {
        return (std::numeric_limits < int > ::min)();
    }
    static int max_value()
    {
        return (std::numeric_limits < int > ::max)();
    }
};

template <class T>
struct GreaterCmp
{
    bool operator ()  (const T & a, const T & b) const
    {
        return a.key > b.key;
    }
    static int min_value()
    {
        return (std::numeric_limits < int > ::max)();
    }
    static int max_value()
    {
        return (std::numeric_limits < int > ::min)();
    }
};

#endif // INCLUDE_USER_TYPES