19#include "absl/log/check.h"
20#include "absl/types/span.h"
24size_t DenseIntDuplicateRemover::RemoveDuplicatesInternal(
25 absl::Span<int> span) {
29 int num_unique_kept = -1;
31 while (++num_unique_kept < span.size()) {
32 const int x = span[num_unique_kept];
34 DCHECK_LT(
x, tmp_mask_.size() * 8);
36 const uint8_t mask = 1u << (
x & 7);
37 const uint8_t
byte = tmp_mask_[
x >> 3];
38 if (mask &
byte)
break;
39 tmp_mask_[
x >> 3] =
byte | mask;
43 for (
int i = num_unique_kept + 1;
i < span.size(); ++
i) {
44 const int x = span[
i];
46 DCHECK_LT(
x, tmp_mask_.size() * 8);
47 const uint8_t mask = 1 << (
x & 7);
48 const uint8_t
byte = tmp_mask_[
x >> 3];
49 if (mask &
byte)
continue;
50 tmp_mask_[
x >> 3] = mask | byte;
51 span[num_unique_kept++] =
x;
53 span.remove_suffix(span.size() - num_unique_kept);
55 for (
int x : span) tmp_mask_[
x >> 3] = 0;
56 return num_unique_kept;
In SWIG mode, we don't want anything besides these top-level includes.