graphalgs
Description
The MexSet data structure is an implementation of a set that can quickly find MEX.
The MEX (Minimum EXcluded) of a subset of the set of natural numbers is the minimum natural number missing from this subset. That is, it is the minimum value of the complement set.
Usage
As a library
use MexSet;
let mut set: = new;
assert_eq!; // The MEX of an empty set is 0
set.insert;
set.insert;
assert_eq!; // 0 is the smallest missing number
set.insert;
assert_eq!; // mex({0, 1, 2}) = 3
set.insert;
assert_eq!; // mex({0, 1, 2, 4}) = 3
set.insert;
assert_eq!; // mex({0, 1, 2, 3, 4}) = 5
set.remove;
assert_eq!; // mex({0, 2, 3, 4}) = 1
If you have any comments or suggestions, or you suddenly found an error, please start a new issue or pool request.