ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
CRoaring.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*----------------------------- File CRoaring.h ----------------------------*/
3
/*--------------------------------------------------------------------------*/
36
/*--------------------------------------------------------------------------*/
37
/*----------------------------- DEFINITIONS --------------------------------*/
38
/*--------------------------------------------------------------------------*/
39
40
#ifndef __ADS_CRoaring
41
#define __ADS_CRoaring
42
/* self-identification: #endif constant */
43
44
/*--------------------------------------------------------------------------*/
45
/*------------------------------ INCLUDES ----------------------------------*/
46
/*--------------------------------------------------------------------------*/
47
48
#include "
ADS/set/RoaringBitmap.h
"
49
50
#include <roaring/roaring.h>
51
#include <roaring/roaring.hh>
52
53
#include <cstddef>
54
#include <new>
55
#include <span>
56
#include <vector>
57
58
/*--------------------------------------------------------------------------*/
59
/*--------------------------- NAMESPACE ------------------------------------*/
60
/*--------------------------------------------------------------------------*/
61
62
namespace
ADS
63
{
64
65
/*--------------------------------------------------------------------------*/
66
/*------------------------------- FUNCTIONS --------------------------------*/
67
/*--------------------------------------------------------------------------*/
68
72
[[nodiscard]]
inline
roaring_bitmap_t *
toCRoaring
(
const
RoaringBitmap
& s )
73
{
74
const
std::vector< std::byte > b = s.
writePortable
();
75
roaring_bitmap_t * r = roaring_bitmap_portable_deserialize_safe(
76
reinterpret_cast<
const
char
*
>
( b.data() ) , b.size() );
77
if
( r ==
nullptr
)
// the bytes are of ADS, only the memory may lack
78
throw
( std::bad_alloc() );
79
return
( r );
80
}
81
84
[[nodiscard]]
inline
RoaringBitmap
fromCRoaring
(
const
roaring_bitmap_t * r )
85
{
86
ADS_PRE
( r !=
nullptr
);
87
std::vector< std::byte > b( roaring_bitmap_portable_size_in_bytes( r ) );
88
roaring_bitmap_portable_serialize( r ,
89
reinterpret_cast<
char
*
>
( b.data() ) );
90
return
(
RoaringBitmap::readPortable
( b ) );
91
}
92
95
[[nodiscard]]
inline
roaring::Roaring
toRoaring
(
const
RoaringBitmap
& s )
96
{
97
const
std::vector< std::byte > b = s.
writePortable
();
98
return
( roaring::Roaring::readSafe(
99
reinterpret_cast<
const
char
*
>
( b.data() ) , b.size() ) );
100
}
101
104
[[nodiscard]]
inline
RoaringBitmap
fromCRoaring
(
const
roaring::Roaring & r )
105
{
106
return
(
fromCRoaring
( &r.roaring ) );
107
}
108
109
/*--------------------------------------------------------------------------*/
110
111
}
// end( namespace ADS )
112
113
/*--------------------------------------------------------------------------*/
114
115
#endif
/* CRoaring.h included */
116
117
/*--------------------------------------------------------------------------*/
118
/*-------------------------- End File CRoaring.h ---------------------------*/
119
/*--------------------------------------------------------------------------*/
RoaringBitmap.h
The compressed bitmap of Chambi, Lemire, Kaser and Godin (Roaring), beyond the book: a SET of integer...
ADS::RoaringBitmap
a set of integers of 32 bits as a Roaring bitmap
Definition
RoaringBitmap.h:158
ADS::RoaringBitmap::writePortable
std::size_t writePortable(std::span< std::byte > out) const
the set written at the start of in the portable format of Roaring, with no container of runs; the by...
ADS::RoaringBitmap::readPortable
static RoaringBitmap readPortable(std::span< const std::byte > in, std::size_t *used=nullptr)
the set written in the portable format of Roaring at the start of , its containers of runs read as ar...
ADS_PRE
#define ADS_PRE(cond)
[check]
Definition
Contract.h:121
ADS::fromCRoaring
RoaringBitmap fromCRoaring(const roaring_bitmap_t *r)
the bitmap of CRoaring as a RoaringBitmap
Definition
CRoaring.h:84
ADS::toCRoaring
roaring_bitmap_t * toCRoaring(const RoaringBitmap &s)
the set as a new bitmap of CRoaring, which the caller frees by roaring_bitmap_free()
Definition
CRoaring.h:72
ADS::toRoaring
roaring::Roaring toRoaring(const RoaringBitmap &s)
the set as a roaring::Roaring of the C++ interface of CRoaring
Definition
CRoaring.h:95
ADS
Definition
ADT.h:96
ADS
interop
croaring
CRoaring.h
Generated by
1.17.0