29
29
#include < cstddef>
30
30
#include < concepts>
31
31
32
+ #include < iostream>
33
+
32
34
33
35
#ifndef GAPP_SEED
34
36
# define GAPP_SEED 0x3da99432ab975d26LL
@@ -457,6 +459,8 @@ namespace gapp::rng
457
459
template <std::integral IntType>
458
460
GAPP_NOINLINE small_vector<IntType> sampleUniqueSet (IntType lbound, IntType ubound, size_t count)
459
461
{
462
+ std::cout << " sampleUniqueSet\n " ;
463
+
460
464
std::unordered_set<IntType> selected (count);
461
465
small_vector<IntType> numbers (count);
462
466
@@ -477,20 +481,29 @@ namespace gapp::rng
477
481
{
478
482
const size_t range_len = detail::range_length (lbound, ubound);
479
483
484
+ std::cout << " Sample unique lbound: " << lbound << " , ubound: " << ubound << " , count: " << count << " \n " ;
485
+
480
486
GAPP_ASSERT (ubound >= lbound);
481
487
GAPP_ASSERT (range_len >= count);
482
488
483
- const bool select_many = (count > 0.6 * range_len);
484
- const bool huge_range = (range_len >= 65536 );
489
+ const bool select_many = std::cmp_greater_equal (count, size_t ( 0.6 * range_len) );
490
+ const bool huge_range = std::cmp_greater_equal (range_len, 65536 );
485
491
486
- if (huge_range) [[unlikely]] return rng::sampleUniqueSet (lbound, ubound, count);
492
+ std::cout << " Range len: " << range_len << " , huge_range: " << huge_range << " \n " ;
493
+ std::cout << " select many: " << select_many << " \n " ;
494
+
495
+ if (huge_range) return rng::sampleUniqueSet (lbound, ubound, count);
496
+
497
+ std::cout << " Sample unique small\n " ;
487
498
488
499
small_vector<IntType> numbers (count);
489
500
490
501
thread_local detail::dynamic_bitset is_selected;
491
502
is_selected.resize (range_len);
492
503
is_selected.fill (select_many);
493
504
505
+ std::cout << " Allocated\n " ;
506
+
494
507
if (!select_many)
495
508
{
496
509
IntType limit = ubound - detail::promoted_t <IntType>(count);
0 commit comments