aboutsummaryrefslogtreecommitdiff
path: root/db/skiplist.cuh
diff options
context:
space:
mode:
authorKunoiSayami <[email protected]>2021-12-13 01:36:45 +0800
committerKunoiSayami <[email protected]>2021-12-13 01:36:45 +0800
commitb338a2083d68b9a8d1e3eb17538535aa050426df (patch)
tree7c7d9e3c65d2ebf437c49b86ac485b1142261c2e /db/skiplist.cuh
parenta2a9e40d917e3a932e5f563743a0f908f38ac2c6 (diff)
test(skiplist): Add insert and check test
Signed-off-by: KunoiSayami <[email protected]>
Diffstat (limited to 'db/skiplist.cuh')
-rw-r--r--db/skiplist.cuh24
1 files changed, 12 insertions, 12 deletions
diff --git a/db/skiplist.cuh b/db/skiplist.cuh
index 4fcd220..8fe864a 100644
--- a/db/skiplist.cuh
+++ b/db/skiplist.cuh
@@ -59,21 +59,21 @@ class SkipList {
__device__ void Insert(const Key& key);
// Returns true iff an entry that compares equal to key is in the list.
- bool Contains(const Key& key) const;
+ __device__ bool Contains(const Key& key) const;
// Iteration over the contents of a skip list
class Iterator {
public:
// Initialize an iterator over the specified list.
// The returned iterator is not valid.
- explicit Iterator(const SkipList* list);
+ __device__ __host__ explicit Iterator(const SkipList* list);
// Returns true iff the iterator is positioned at a valid node.
- bool Valid() const;
+ __device__ __host__ bool Valid() const;
// Returns the key at the current position.
// REQUIRES: Valid()
- const Key& key() const;
+ __device__ const Key& key() const;
// Advances to the next position.
// REQUIRES: Valid()
@@ -88,11 +88,11 @@ class SkipList {
// Position at the first entry in list.
// Final state of iterator is Valid() iff list is not empty.
- void SeekToFirst();
+ __device__ void SeekToFirst();
// Position at the last entry in list.
// Final state of iterator is Valid() iff list is not empty.
- void SeekToLast();
+ __device__ void SeekToLast();
private:
const SkipList* list_;
@@ -209,18 +209,18 @@ __device__ typename SkipList<Key, Comparator>::Node* SkipList<Key, Comparator>::
}
template <typename Key, class Comparator>
-inline SkipList<Key, Comparator>::Iterator::Iterator(const SkipList* list) {
+__device__ __host__ inline SkipList<Key, Comparator>::Iterator::Iterator(const SkipList* list) {
list_ = list;
node_ = nullptr;
}
template <typename Key, class Comparator>
-inline bool SkipList<Key, Comparator>::Iterator::Valid() const {
+__device__ __host__ inline bool SkipList<Key, Comparator>::Iterator::Valid() const {
return node_ != nullptr;
}
template <typename Key, class Comparator>
-inline const Key& SkipList<Key, Comparator>::Iterator::key() const {
+__device__ inline const Key& SkipList<Key, Comparator>::Iterator::key() const {
assert(Valid());
return node_->key;
}
@@ -248,12 +248,12 @@ __device__ inline void SkipList<Key, Comparator>::Iterator::Seek(const Key& targ
}
template <typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::SeekToFirst() {
+__device__ inline void SkipList<Key, Comparator>::Iterator::SeekToFirst() {
node_ = list_->head_->Next(0);
}
template <typename Key, class Comparator>
-inline void SkipList<Key, Comparator>::Iterator::SeekToLast() {
+__device__ inline void SkipList<Key, Comparator>::Iterator::SeekToLast() {
node_ = list_->FindLast();
if (node_ == list_->head_) {
node_ = nullptr;
@@ -390,7 +390,7 @@ __device__ void SkipList<Key, Comparator>::Insert(const Key& key) {
}
template <typename Key, class Comparator>
-bool SkipList<Key, Comparator>::Contains(const Key& key) const {
+__device__ bool SkipList<Key, Comparator>::Contains(const Key& key) const {
Node* x = FindGreaterOrEqual(key, nullptr);
if (x != nullptr && Equal(key, x->key)) {
return true;