forked from facebookarchive/fbcuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pair.cuh
42 lines (32 loc) · 950 Bytes
/
Pair.cuh
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
// Copyright 2004-present Facebook. All Rights Reserved.
#pragma once
#include <cuda.h>
namespace facebook { namespace cuda {
/// A simple pair type for CUDA device usage
template <typename K, typename V>
struct Pair {
__host__ __device__ __forceinline__ Pair() {
}
__host__ __device__ __forceinline__ Pair(K key, V value)
: k(key), v(value) {
}
__host__ __device__ __forceinline__ bool
operator==(const Pair<K, V>& rhs) const {
return (k == rhs.k) && (v == rhs.v);
}
__host__ __device__ __forceinline__ bool
operator!=(const Pair<K, V>& rhs) const {
return !operator==(rhs);
}
__host__ __device__ __forceinline__ bool
operator<(const Pair<K, V>& rhs) const {
return (k < rhs.k) || ((k == rhs.k) && (v < rhs.v));
}
__host__ __device__ __forceinline__ bool
operator>(const Pair<K, V>& rhs) const {
return (k > rhs.k) || ((k == rhs.k) && (v > rhs.v));
}
K k;
V v;
};
} } // namespace