From b338a2083d68b9a8d1e3eb17538535aa050426df Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Mon, 13 Dec 2021 01:36:45 +0800 Subject: test(skiplist): Add insert and check test Signed-off-by: KunoiSayami --- db/skiplist.cuh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'db/skiplist.cuh') 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::Node* SkipList:: } template -inline SkipList::Iterator::Iterator(const SkipList* list) { +__device__ __host__ inline SkipList::Iterator::Iterator(const SkipList* list) { list_ = list; node_ = nullptr; } template -inline bool SkipList::Iterator::Valid() const { +__device__ __host__ inline bool SkipList::Iterator::Valid() const { return node_ != nullptr; } template -inline const Key& SkipList::Iterator::key() const { +__device__ inline const Key& SkipList::Iterator::key() const { assert(Valid()); return node_->key; } @@ -248,12 +248,12 @@ __device__ inline void SkipList::Iterator::Seek(const Key& targ } template -inline void SkipList::Iterator::SeekToFirst() { +__device__ inline void SkipList::Iterator::SeekToFirst() { node_ = list_->head_->Next(0); } template -inline void SkipList::Iterator::SeekToLast() { +__device__ inline void SkipList::Iterator::SeekToLast() { node_ = list_->FindLast(); if (node_ == list_->head_) { node_ = nullptr; @@ -390,7 +390,7 @@ __device__ void SkipList::Insert(const Key& key) { } template -bool SkipList::Contains(const Key& key) const { +__device__ bool SkipList::Contains(const Key& key) const { Node* x = FindGreaterOrEqual(key, nullptr); if (x != nullptr && Equal(key, x->key)) { return true; -- cgit v1.3.1