59 {
61 unsigned i = min_bucket;
62 for (;;) {
65 std::vector<unsigned> &s = buckets[i];
66 if (s.empty ()) {
67 min_bucket = ++i;
68 continue;
69 }
70 unsigned res;
71 if (i) {
72 res = UINT_MAX;
73 const auto begin = std::begin (s);
74 const auto end = std::end (s);
75 auto q = std::begin (s);
77 for (
auto p = begin;
p != end; ++
p) {
78 const unsigned tmp = *
p;
79 if (tmp >= res)
80 continue;
81 res = tmp;
83 }
84
85 for (
auto p = begin;
p != end; ++
p) {
87 continue;
88 const unsigned other = *
p;
89 const unsigned diff = other ^ res;
91 const unsigned j = 32 - leading_zeroes_of_unsigned (diff);
93 buckets[j].push_back (other);
94 if (min_bucket > j)
95 min_bucket = j;
96 }
97
98 s.clear ();
99
100 if (i && max_bucket == i) {
101#ifndef CADICAL_NDEBUG
102 for (unsigned j = i + 1; j < 33; j++)
104#endif
105 if (s.empty ())
106 max_bucket = i - 1;
107 }
108 } else {
109 res = last_deleted;
112 buckets[0].pop_back ();
113 }
114
115 if (min_bucket == i) {
116#ifndef CADICAL_NDEBUG
117 for (unsigned j = 0; j < i; j++)
119#endif
120 if (s.empty ())
121 min_bucket = std::min ((int) (i + 1), 32);
122 }
123
124 --num_elements;
126 last_deleted = res;
127
128 return res;
129 }
130}