import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import java.util.Collection;
import java.util.Collections;
import java.util.NavigableSet;
import java.util.TreeSet;
return UnsignedLong.fromLongBits(upperBits);
}
- boolean contains(final long longBits) {
- return Long.compareUnsigned(lowerBits, longBits) <= 0 && Long.compareUnsigned(upperBits, longBits) >= 0;
- }
-
Entry copy() {
return new Entry(lowerBits, upperBits);
}
public final boolean contains(final long longBits) {
final var head = ranges.floor(Entry.of(longBits));
- return head != null && head.contains(longBits);
+ return head != null
+ && Long.compareUnsigned(head.lowerBits, longBits) <= 0
+ && Long.compareUnsigned(head.upperBits, longBits) >= 0;
}
public final boolean isEmpty() {
public abstract @NonNull ImmutableUnsignedLongSet immutableCopy();
public final @NonNull MutableUnsignedLongSet mutableCopy() {
- return new MutableUnsignedLongSet(new TreeSet<>(Collections2.transform(ranges, Entry::copy)));
+ return new MutableUnsignedLongSet(new TreeSet<>(copiedRanges()));
}
public final @NonNull NavigableSet<Entry> ranges() {
return ranges;
}
+ final @NonNull Collection<Entry> copiedRanges() {
+ return Collections2.transform(ranges, Entry::copy);
+ }
+
@Override
public final int hashCode() {
return ranges.hashCode();