@@ -168,21 +168,15 @@ inline auto add_int_class(py::module& m, py::dict& dict, KEY_T key,
168168 return cls;
169169}
170170
171- template <typename VectorT>
172- auto add_int_vector (py::module & m, py::dict& int_vectors_dict) {
173- size_t width = VectorT::fixed_int_width;
174- std::string name = " Int" + std::to_string (width) + " Vector" ;
175- return add_int_class<VectorT, typename VectorT::value_type>(
176- m, int_vectors_dict, width, name.c_str ())
177- .def (py::init (
178- [width](size_t size, typename VectorT::value_type default_value) {
179- return VectorT (size, default_value, width); }),
180- py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 );
181- }
182171
183- template <>
184- auto add_int_vector<sdsl::int_vector<0 >>(py::module & m, py::dict& int_vectors_dict) {
185- return add_int_class<sdsl::int_vector<0 >>(
172+ inline auto add_int_vectors (py::module & m)
173+ {
174+ py::dict int_vectors_dict;
175+
176+ m.attr (" int_vector" ) = int_vectors_dict;
177+
178+ return std::make_tuple (
179+ add_int_class<sdsl::int_vector<0 >>(
186180 m, int_vectors_dict, " dynamic" , " IntVector" , doc_int_vector)
187181 .def (
188182 py::init ([](size_t size,
@@ -204,54 +198,59 @@ auto add_int_vector<sdsl::int_vector<0>>(py::module& m, py::dict& int_vectors_di
204198 [](sdsl::int_vector<0 > &self) {
205199 sdsl::util::bit_compress (self); },
206200 doc_bit_compress,
207- py::call_guard<py::gil_scoped_release>());
208- }
201+ py::call_guard<py::gil_scoped_release>()),
209202
210- template <>
211- auto add_int_vector<sdsl::int_vector<1 >>(py::module & m, py::dict& int_vectors_dict) {
212- return add_int_class<sdsl::int_vector<1 >, bool >(
203+ add_int_class<sdsl::int_vector<1 >, bool >(
213204 m, int_vectors_dict, 1ul , " BitVector" )
214205 .def (py::init (
215206 [](size_t size, bool default_value) {
216207 return sdsl::int_vector<1 >(size, default_value, 1 ); }),
217208 py::arg (" size" ) = 0 , py::arg (" default_value" ) = false )
218209 .def (" flip" , &sdsl::int_vector<1 >::flip,
219210 " Flip all bits of bit_vector" ,
220- py::call_guard<py::gil_scoped_release>());
221- }
211+ py::call_guard<py::gil_scoped_release>()),
222212
213+ add_int_class<sdsl::int_vector<4 >, uint16_t >(
214+ m, int_vectors_dict, 4 , " Int4Vector" )
215+ .def (py::init (
216+ [](size_t size, uint8_t default_value) {
217+ return sdsl::int_vector<4 >(size, default_value, 4 ); }),
218+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 ),
223219
224- template <typename ... VectorT>
225- auto make_int_vectors (py::module & m, py::dict& int_vectors_dict) {
226- return std::make_tuple (add_int_vector<VectorT>(m, int_vectors_dict)...);
227- }
220+ add_int_class<sdsl::int_vector<8 >, uint16_t >(
221+ m, int_vectors_dict, 8 , " Int8Vector" )
222+ .def (py::init (
223+ [](size_t size, uint8_t default_value) {
224+ return sdsl::int_vector<8 >(size, default_value, 8 ); }),
225+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 ),
228226
227+ add_int_class<sdsl::int_vector<16 >, uint16_t >(
228+ m, int_vectors_dict, 16 , " Int16Vector" )
229+ .def (py::init (
230+ [](size_t size, uint16_t default_value) {
231+ return sdsl::int_vector<16 >(size, default_value, 16 ); }),
232+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 ),
229233
230- inline auto add_int_vectors (py::module & m)
231- {
232- py::dict int_vectors_dict;
234+ add_int_class<sdsl::int_vector<24 >, uint32_t >(
235+ m, int_vectors_dict, 24 , " Int24Vector" )
236+ .def (py::init (
237+ [](size_t size, uint32_t default_value) {
238+ return sdsl::int_vector<24 >(size, default_value, 24 ); }),
239+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 ),
233240
234- m.attr (" int_vector" ) = int_vectors_dict;
241+ add_int_class<sdsl::int_vector<32 >, uint32_t >(
242+ m, int_vectors_dict, 32 , " Int32Vector" )
243+ .def (py::init (
244+ [](size_t size, uint32_t default_value) {
245+ return sdsl::int_vector<32 >(size, default_value, 32 ); }),
246+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 ),
235247
236- return make_int_vectors<sdsl::int_vector<0 >,
237- sdsl::int_vector<1 >,
238- sdsl::int_vector<4 >,
239- sdsl::int_vector<8 >,
240- sdsl::int_vector<16 >,
241- sdsl::int_vector<24 >,
242- sdsl::int_vector<32 >,
243- sdsl::int_vector<48 >,
244- sdsl::int_vector<64 >>(m, int_vectors_dict);
245-
246- // #define DEF_INC_VECTOR(width, value_type) ,\
247- // add_int_class<sdsl::int_vector<width>, value_type>( \
248- // m, int_vectors_dict, width, "Int" #width "Vector") \
249- // .def(py::init( \
250- // [](size_t size, value_type default_value) { \
251- // return sdsl::int_vector<width>(size, default_value, width); }), \
252- // py::arg("size") = 0, py::arg("default_value") = 0)
253- // #include "int_vectors.h"
254- // #undef DEF_INC_VECTOR
255- // );
248+ add_int_class<sdsl::int_vector<64 >, uint64_t >(
249+ m, int_vectors_dict, 64 , " Int64Vector" )
250+ .def (py::init (
251+ [](size_t size, uint64_t default_value) {
252+ return sdsl::int_vector<64 >(size, default_value, 64 ); }),
253+ py::arg (" size" ) = 0 , py::arg (" default_value" ) = 0 )
254+ );
256255
257256}
0 commit comments