Skip to content

Commit 18acbed

Browse files
committed
Add empty()
1 parent 5977bea commit 18acbed

File tree

4 files changed

+55
-36
lines changed

4 files changed

+55
-36
lines changed

include/cuco/detail/roaring_bitmap/roaring_bitmap.inl

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
#pragma once
1718

1819
#include <cuco/detail/error.hpp>
@@ -25,9 +26,9 @@
2526
namespace cuco {
2627

2728
template <class T, class Allocator>
28-
__host__ roaring_bitmap<T, Allocator>::roaring_bitmap(cuda::std::byte const* bitmap,
29-
Allocator const& alloc,
30-
cuda::stream_ref stream)
29+
roaring_bitmap<T, Allocator>::roaring_bitmap(cuda::std::byte const* bitmap,
30+
Allocator const& alloc,
31+
cuda::stream_ref stream)
3132
: allocator_{alloc},
3233
metadata_{ref_type::read_metadata(bitmap)},
3334
data_{
@@ -42,52 +43,57 @@ __host__ roaring_bitmap<T, Allocator>::roaring_bitmap(cuda::std::byte const* bit
4243

4344
template <class T, class Allocator>
4445
template <class InputIt, class OutputIt>
45-
__host__ void roaring_bitmap<T, Allocator>::contains(InputIt first,
46-
InputIt last,
47-
OutputIt output,
48-
cuda::stream_ref stream) const
46+
void roaring_bitmap<T, Allocator>::contains(InputIt first,
47+
InputIt last,
48+
OutputIt output,
49+
cuda::stream_ref stream) const
4950
{
5051
ref_.contains(first, last, output, stream);
5152
}
5253

5354
template <class T, class Allocator>
5455
template <class InputIt, class OutputIt>
55-
__host__ void roaring_bitmap<T, Allocator>::contains_async(InputIt first,
56-
InputIt last,
57-
OutputIt output,
58-
cuda::stream_ref stream) const noexcept
56+
void roaring_bitmap<T, Allocator>::contains_async(InputIt first,
57+
InputIt last,
58+
OutputIt output,
59+
cuda::stream_ref stream) const noexcept
5960
{
6061
ref_.contains_async(first, last, output, stream);
6162
}
6263

6364
template <class T, class Allocator>
64-
__host__ cuda::std::size_t roaring_bitmap<T, Allocator>::size() const noexcept
65+
cuda::std::size_t roaring_bitmap<T, Allocator>::size() const noexcept
6566
{
6667
return ref_.size();
6768
}
6869

6970
template <class T, class Allocator>
70-
__host__ cuda::std::byte const* roaring_bitmap<T, Allocator>::data() const noexcept
71+
bool roaring_bitmap<T, Allocator>::empty() const noexcept
72+
{
73+
return ref_.empty();
74+
}
75+
76+
template <class T, class Allocator>
77+
cuda::std::byte const* roaring_bitmap<T, Allocator>::data() const noexcept
7178
{
7279
return ref_.data();
7380
}
7481

7582
template <class T, class Allocator>
76-
__host__ cuda::std::size_t roaring_bitmap<T, Allocator>::size_bytes() const noexcept
83+
cuda::std::size_t roaring_bitmap<T, Allocator>::size_bytes() const noexcept
7784
{
7885
return ref_.size_bytes();
7986
}
8087

8188
template <class T, class Allocator>
82-
__host__ typename roaring_bitmap<T, Allocator>::allocator_type
83-
roaring_bitmap<T, Allocator>::allocator() const noexcept
89+
typename roaring_bitmap<T, Allocator>::allocator_type roaring_bitmap<T, Allocator>::allocator()
90+
const noexcept
8491
{
8592
return allocator_;
8693
}
8794

8895
template <class T, class Allocator>
89-
__host__ typename roaring_bitmap<T, Allocator>::ref_type roaring_bitmap<T, Allocator>::ref()
90-
const noexcept
96+
typename roaring_bitmap<T, Allocator>::ref_type roaring_bitmap<T, Allocator>::ref() const noexcept
9197
{
9298
return ref_;
9399
}

include/cuco/detail/roaring_bitmap/roaring_bitmap_ref.inl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
#pragma once
1718

1819
#include <cuco/detail/roaring_bitmap/roaring_bitmap_impl.cuh>
@@ -69,6 +70,12 @@ __host__ __device__ cuda::std::size_t roaring_bitmap_ref<T>::size() const noexce
6970
return impl_.size();
7071
}
7172

73+
template <class T>
74+
__host__ __device__ bool roaring_bitmap_ref<T>::empty() const noexcept
75+
{
76+
return impl_.empty();
77+
}
78+
7279
template <class T>
7380
__host__ __device__ cuda::std::byte const* roaring_bitmap_ref<T>::data() const noexcept
7481
{

include/cuco/roaring_bitmap.cuh

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
#pragma once
1718

1819
#include <cuco/detail/storage/storage_base.cuh>
@@ -33,9 +34,9 @@ class roaring_bitmap {
3334

3435
using ref_type = roaring_bitmap_ref<T>;
3536

36-
__host__ roaring_bitmap(cuda::std::byte const* bitmap,
37-
Allocator const& alloc = {},
38-
cuda::stream_ref stream = {});
37+
roaring_bitmap(cuda::std::byte const* bitmap,
38+
Allocator const& alloc = {},
39+
cuda::stream_ref stream = {});
3940

4041
roaring_bitmap(roaring_bitmap const& other) = default;
4142
roaring_bitmap(roaring_bitmap&& other) = default;
@@ -45,28 +46,30 @@ class roaring_bitmap {
4546
~roaring_bitmap() = default;
4647

4748
template <class InputIt, class OutputIt>
48-
__host__ void contains(InputIt first,
49-
InputIt last,
50-
OutputIt contained,
51-
cuda::stream_ref stream = {}) const;
49+
void contains(InputIt first,
50+
InputIt last,
51+
OutputIt contained,
52+
cuda::stream_ref stream = {}) const;
5253

5354
template <class InputIt, class OutputIt>
54-
__host__ void contains_async(InputIt first,
55-
InputIt last,
56-
OutputIt contained,
57-
cuda::stream_ref stream = {}) const noexcept;
55+
void contains_async(InputIt first,
56+
InputIt last,
57+
OutputIt contained,
58+
cuda::stream_ref stream = {}) const noexcept;
5859

5960
// TODO contains_if, contains_if_async, empty
6061

61-
[[nodiscard]] __host__ cuda::std::size_t size() const noexcept;
62+
[[nodiscard]] cuda::std::size_t size() const noexcept;
63+
64+
[[nodiscard]] bool empty() const noexcept;
6265

63-
[[nodiscard]] __host__ cuda::std::byte const* data() const noexcept;
66+
[[nodiscard]] cuda::std::byte const* data() const noexcept;
6467

65-
[[nodiscard]] __host__ cuda::std::size_t size_bytes() const noexcept;
68+
[[nodiscard]] cuda::std::size_t size_bytes() const noexcept;
6669

67-
[[nodiscard]] __host__ allocator_type allocator() const noexcept;
70+
[[nodiscard]] allocator_type allocator() const noexcept;
6871

69-
[[nodiscard]] __host__ ref_type ref() const noexcept;
72+
[[nodiscard]] ref_type ref() const noexcept;
7073

7174
private:
7275
allocator_type allocator_;

include/cuco/roaring_bitmap_ref.cuh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
#pragma once
1718

1819
#include <cuco/detail/roaring_bitmap/roaring_bitmap_impl.cuh>
@@ -32,8 +33,8 @@ class roaring_bitmap_ref {
3233
__host__ __device__ roaring_bitmap_ref(cuda::std::byte const* bitmap,
3334
metadata_type const& metadata);
3435

35-
template <typename U = T,
36-
typename = cuda::std::enable_if_t<cuda::std::is_same_v<U, cuda::std::uint32_t>>>
36+
template <class U = T,
37+
class = cuda::std::enable_if_t<cuda::std::is_same_v<U, cuda::std::uint32_t>>>
3738
__device__ roaring_bitmap_ref(cuda::std::byte const* bitmap);
3839

3940
template <class InputIt, class OutputIt>
@@ -52,6 +53,8 @@ class roaring_bitmap_ref {
5253

5354
[[nodiscard]] __host__ __device__ cuda::std::size_t size() const noexcept;
5455

56+
[[nodiscard]] __host__ __device__ bool empty() const noexcept;
57+
5558
[[nodiscard]] __host__ __device__ cuda::std::byte const* data() const noexcept;
5659

5760
[[nodiscard]] __host__ __device__ cuda::std::size_t size_bytes() const noexcept;

0 commit comments

Comments
 (0)