Skip to content

Commit 8256aec

Browse files
committed
feat: removed XORBasis.min(), added XORBasis.size().
1 parent 1b9f26e commit 8256aec

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

src/alfred/math/linear.hpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ struct XORBasis {
132132
constexpr static T mx = std::numeric_limits<T>::max();
133133
constexpr static int C = std::__lg(mx);
134134

135+
int siz = 0;
135136
std::array<T, C> p;
136137
bool has_zero = false;
137138
// Insert x to the basis.
@@ -141,7 +142,7 @@ struct XORBasis {
141142
for (int i = C - 1; i >= 0; i--) {
142143
if (!(x >> i & 1)) continue;
143144
if (p[i] == 0) {
144-
p[i] = x;
145+
p[i] = x, siz++;
145146
return i;
146147
} else x ^= p[i];
147148
}
@@ -159,17 +160,7 @@ struct XORBasis {
159160
}
160161
return ans;
161162
}
162-
inline T min(void) {
163-
T lst = 0;
164-
bool all_zero = true;
165-
if (has_zero) return 0;
166-
for (int i = C - 1; i >= 0; i--) {
167-
if (p[i] != 0) {
168-
all_zero = false, lst = p[i];
169-
}
170-
}
171-
return all_zero ? mx : lst;
172-
}
163+
inline int size(void) { return siz; }
173164
};
174165

175166
#endif // !AFMT_LINEAR

0 commit comments

Comments
 (0)