Skip to content

Commit

Permalink
add occupied(n) for unordered set and map
Browse files Browse the repository at this point in the history
  • Loading branch information
tanzby committed Aug 8, 2024
1 parent 3b7d712 commit 87fe7d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/stdgpu/impl/unordered_map_detail.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,13 @@ unordered_map<Key, T, Hash, KeyEqual, Allocator>::clear(ExecutionPolicy&& policy
_base.clear(std::forward<ExecutionPolicy>(policy));
}

template <typename Key, typename T, typename Hash, typename KeyEqual, typename Allocator>
inline STDGPU_DEVICE_ONLY bool
unordered_map<Key, T, Hash, KeyEqual, Allocator>::occupied(const index_t n) const

Check warning on line 363 in src/stdgpu/impl/unordered_map_detail.cuh

View check run for this annotation

Codecov / codecov/patch

src/stdgpu/impl/unordered_map_detail.cuh#L363

Added line #L363 was not covered by tests
{
return _base.occupied(n);

Check warning on line 365 in src/stdgpu/impl/unordered_map_detail.cuh

View check run for this annotation

Codecov / codecov/patch

src/stdgpu/impl/unordered_map_detail.cuh#L365

Added line #L365 was not covered by tests
}

template <typename Key, typename T, typename Hash, typename KeyEqual, typename Allocator>
unordered_map<Key, T, Hash, KeyEqual, Allocator>
unordered_map<Key, T, Hash, KeyEqual, Allocator>::createDeviceObject(const index_t& capacity,
Expand Down
7 changes: 7 additions & 0 deletions src/stdgpu/impl/unordered_set_detail.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,13 @@ unordered_set<Key, Hash, KeyEqual, Allocator>::clear(ExecutionPolicy&& policy)
_base.clear(std::forward<ExecutionPolicy>(policy));
}

template <typename Key, typename Hash, typename KeyEqual, typename Allocator>
inline STDGPU_DEVICE_ONLY bool
unordered_set<Key, Hash, KeyEqual, Allocator>::occupied(const index_t n) const

Check warning on line 345 in src/stdgpu/impl/unordered_set_detail.cuh

View check run for this annotation

Codecov / codecov/patch

src/stdgpu/impl/unordered_set_detail.cuh#L345

Added line #L345 was not covered by tests
{
return _base.occupied(n);

Check warning on line 347 in src/stdgpu/impl/unordered_set_detail.cuh

View check run for this annotation

Codecov / codecov/patch

src/stdgpu/impl/unordered_set_detail.cuh#L347

Added line #L347 was not covered by tests
}

template <typename Key, typename Hash, typename KeyEqual, typename Allocator>
unordered_set<Key, Hash, KeyEqual, Allocator>
unordered_set<Key, Hash, KeyEqual, Allocator>::createDeviceObject(const index_t& capacity, const Allocator& allocator)
Expand Down
8 changes: 8 additions & 0 deletions src/stdgpu/unordered_map.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ public:
STDGPU_HOST_DEVICE key_equal
key_eq() const;

/**
* \brief Checks if the given bucket is occupied
* \param[in] n The bucket index
* \return True if the bucket is occupied, false otherwise
*/
STDGPU_DEVICE_ONLY bool
occupied(const index_t n) const;

private:
using base_type =
detail::unordered_base<key_type, value_type, detail::select1st<value_type>, hasher, key_equal, Allocator>;
Expand Down
8 changes: 8 additions & 0 deletions src/stdgpu/unordered_set.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,14 @@ public:
STDGPU_HOST_DEVICE key_equal
key_eq() const;

/**
* \brief Checks if the given bucket is occupied
* \param[in] n The bucket index
* \return True if the bucket is occupied, false otherwise
*/
STDGPU_DEVICE_ONLY bool
occupied(const index_t n) const;

private:
using base_type = detail::unordered_base<key_type, value_type, identity, hasher, key_equal, Allocator>;

Expand Down

0 comments on commit 87fe7d7

Please sign in to comment.