Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
250,100
LongRangeSet (@Nullable RelationType relation) { if (isEmpty() || relation == null) return null; return switch (relation) { case EQ -> this; case NE -> { long min = min(); if (min == max()) yield all().without(min); yield all(); } case GT -> { long min = min(); yield min == Long.MAX_VALUE ? empty() : range(min + 1, Lon...
fromRelation
250,101
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (Point.ZERO.equals(this)) return this; if (Point.ZERO.equals(other)) return other; if (Point.ONE.equals(this)) return other; if (Point.ONE.equals(other)) return this; if (Point.ZERO.equals(this.mod(point(2))) || Point.ZERO.equals(other.mod(point(2)))) { retur...
mulWiden
250,102
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (this instanceof Point && other instanceof Point) { long val1 = ((Point)this).myValue; long val2 = ((Point)other).myValue; int tzb1 = val1 == 0 ? 0 : Long.numberOfTrailingZeros(val1); int tzb2 = val2 == 0 ? 0 : Long.numberOfTrailingZeros(val2); LongRangeSet c...
plusWiden
250,103
LongRangeSet (LongRangeSet other, LongRangeType lrType) { return plus(other.negate(lrType), lrType); }
minus
250,104
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (this.isEmpty() || other.isEmpty()) return empty(); LongRangeSet result = fromBits(getBitwiseMask().or(other.getBitwiseMask())); return result.meet(lrType.fullRange()); }
bitwiseOr
250,105
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (this.isEmpty() || other.isEmpty()) return empty(); LongRangeSet result = fromBits(getBitwiseMask().xor(other.getBitwiseMask())); return result.meet(lrType.fullRange()); }
bitwiseXor
250,106
LongRangeSet (LongRangeSet other) { if (this.isEmpty() || other.isEmpty()) return empty(); long[] left = splitAtZero(asRangeArray()); long[] right = splitAtZero(other.asRangeArray()); // More than three intervals --> convert to single interval to make result more compact (though probably less precise) if (left.length >...
bitwiseAnd
250,107
LongRangeSet (LongRangeSet multiplier, LongRangeType lrType) { if (multiplier.isEmpty()) return multiplier; if (multiplier instanceof Point) return multiplier.mul(this, lrType); BitString thisMask = getBitwiseMask(); BitString thatMask = multiplier.getBitwiseMask(); int numZeros = Math.min(6, Math.min(Long.numberOfTrai...
mul
250,108
LongRangeSet (LongRangeSet divisor, LongRangeType lrType) { if (divisor.isEmpty() || divisor.equals(Point.ZERO)) return empty(); divisor = divisor.meet(lrType.fullRange()); LongRangeSet dividend = this.meet(lrType.fullRange()); long[] left = splitAtZero(dividend.asRangeArray()); long[] right = splitAtZero(new long[]{di...
div
250,109
boolean (@NotNull LongRangeSet other, LongRangeType lrType) { return subtractionMayOverflow(other.negate(lrType), lrType); }
additionMayOverflow
250,110
boolean (@NotNull LongRangeSet other, LongRangeType lrType) { long leftMin = min(); long leftMax = max(); long rightMin = other.min(); long rightMax = other.max(); return lrType.subtractionMayOverflow(leftMin, rightMax) || lrType.subtractionMayOverflow(leftMax, rightMin); }
subtractionMayOverflow
250,111
LongRangeSet (long dividendMin, long dividendMax, long divisorMin, long divisorMax, LongRangeType lrType) { if (divisorMin == 0) { if (divisorMax == 0) return empty(); divisorMin = 1; } if (dividendMin >= 0) { return divisorMin > 0 ? range(dividendMin / divisorMax, dividendMax / divisorMin) : range(dividendMax / diviso...
divide
250,112
LongRangeSet (LongRangeSet shiftSize, LongRangeType lrType) { if (isEmpty() || shiftSize.isEmpty()) return empty(); if (shiftSize instanceof Point) { long shift = ((Point)shiftSize).myValue & (lrType.bits() - 1); return point(1L << shift).mul(this, lrType); } return lrType.fullRange(); }
shiftLeft
250,113
LongRangeSet (LongRangeSet shiftSize, LongRangeType lrType) { return doShiftRight(shiftSize, lrType, false); }
shiftRight
250,114
LongRangeSet (LongRangeSet shiftSize, LongRangeType lrType) { return doShiftRight(shiftSize, lrType, true); }
unsignedShiftRight
250,115
LongRangeSet (LongRangeSet shiftSize, LongRangeType lrType, boolean unsigned) { if (isEmpty() || shiftSize.isEmpty()) return empty(); int maxShift = lrType.bits() - 1; if (shiftSize.min() < 0 || shiftSize.max() > maxShift) { shiftSize = shiftSize.bitwiseAnd(point(maxShift)); } long min = shiftSize.min(); long max = shi...
doShiftRight
250,116
LongRangeSet (long min, long max, LongRangeType lrType) { if (isEmpty()) return empty(); int maxShift = lrType.bits() - 1; if (max == maxShift) { return min == max ? Point.ZERO : Point.ZERO.join(div(range(1L << min, 1L << (max - 1)), lrType)); } return div(range(1L << min, 1L << max), lrType); }
shrPositive
250,117
long[] (long[] ranges) { for (int i = 0; i < ranges.length; i += 2) { if (ranges[i] < 0 && ranges[i + 1] >= 0) { long[] result = new long[ranges.length + 2]; System.arraycopy(ranges, 0, result, 0, i + 1); result[i + 1] = -1; System.arraycopy(ranges, i + 1, result, i + 3, ranges.length - i - 1); return result; } } retur...
splitAtZero
250,118
LongRangeSet (long leftFrom, long leftTo, long rightFrom, long rightTo, BitString globalMask) { BitString leftBits = BitString.fromRange(leftFrom, leftTo); BitString rightBits = BitString.fromRange(rightFrom, rightTo); LongRangeSet fromBits = fromBits(leftBits.and(rightBits).and(globalMask)); if (leftFrom == leftTo && ...
bitwiseAnd
250,119
LongRangeSet (long from, long to, long mask) { if (to - from > mask) return range(0, mask); long min = from & mask; long max = to & mask; assert min != max; if (min < max) return range(min, max); return new RangeSet(new long[] {0, max, min, mask}); }
bitwiseMask
250,120
LongRangeSet (BitString bits) { if (bits.myMask == -1) { return point(bits.myBits); } long from = 0; int i = Long.SIZE - 1; while (i >= 0 && bits.get(i) != ThreeState.UNSURE) { if (bits.get(i) == ThreeState.YES) { from = setBit(from, i); } i--; } long to = ((i == Long.SIZE - 1 ? 0 : 1L << (i + 1)) - 1) | from; int j = ...
fromBits
250,121
LongRangeSet () { return Empty.EMPTY; }
empty
250,122
LongRangeSet () { return Range.LONG_RANGE; }
all
250,123
LongRangeSet (long value) { return value == 0 ? Point.ZERO : value == 1 ? Point.ONE : new Point(value); }
point
250,124
LongRangeSet (long from, long to) { return from == to ? point(from) : new Range(from, to); }
range
250,125
LongRangeSet (long from, long to, long mod, long bits) { if (mod <= 0) throw new IllegalArgumentException(); if (bits == 0) return empty(); if (mod == 1 || mod > Long.SIZE) return range(from, to); int intMod = (int)mod; // Adjust from/to: they should point to minimal/maximal value which is actually allowed by mod bits ...
modRange
250,126
String (long from, long to) { return formatNumber(from) + (from == to ? "" : (to - from == 1 ? ", " : "..") + formatNumber(to)); }
toString
250,127
LongRangeSet (long[] ranges, int bound) { if (bound == 0) { return Empty.EMPTY; } else if (bound == 2) { return range(ranges[0], ranges[1]); } else { return new RangeSet(Arrays.copyOf(ranges, bound)); } }
fromRanges
250,128
LongRangeSet (long mod, LongRangeSet remainders) { if (remainders.isEmpty()) return empty(); long min = remainders.min() > 0 ? 1 : Long.MIN_VALUE; long max = remainders.max() < 0 ? -1 : Long.MAX_VALUE; if (mod > 1 && mod <= Long.SIZE) { long bits = remainders.contains(0) ? 1 : 0; for(int rem = 1; rem < mod; rem++) { if...
fromRemainder
250,129
LongRangeSet (@NotNull LongRangeSet other) { return this; }
subtract
250,130
LongRangeSet (@NotNull LongRangeSet other) { return this; }
meet
250,131
LongRangeSet (@NotNull LongRangeSet other) { return other; }
join
250,132
LongRangeSet (@NotNull LongRangeSet other) { return other; }
tryJoinExactly
250,133
long () { throw new NoSuchElementException(); }
min
250,134
long () { throw new NoSuchElementException(); }
max
250,135
boolean (LongRangeSet other) { return false; }
intersects
250,136
boolean (long value) { return false; }
contains
250,137
boolean (@NotNull LongRangeSet other) { return other.isEmpty(); }
contains
250,138
String (@NotNull LongRangeSet fullTypeRange) { return InspectionsBundle.message("long.range.set.presentation.empty"); }
getPresentationText
250,139
boolean (long cutoff) { return cutoff < 0; }
isCardinalityBigger
250,140
LongRangeSet (LongRangeType lrType) { return this; }
abs
250,141
LongRangeSet (LongRangeType lrType) { return this; }
negate
250,142
LongRangeSet (LongRangeSet other, LongRangeType lrType) { return this; }
plus
250,143
LongRangeSet (LongRangeSet multiplier, LongRangeType lrType) { return this; }
mul
250,144
LongRangeSet (LongRangeSet divisor) { return empty(); }
mod
250,145
LongStream () { return LongStream.empty(); }
stream
250,146
List<LongRangeSet> () { return Collections.emptyList(); }
asRanges
250,147
int () { return 2154231; }
hashCode
250,148
boolean (Object obj) { return obj == this; }
equals
250,149
String () { return "{}"; }
toString
250,150
String (@NotNull LongRangeSet fullTypeRange) { return formatNumber(myValue); }
getPresentationText
250,151
boolean (long cutoff) { return cutoff < 1; }
isCardinalityBigger
250,152
LongRangeSet (@NotNull LongRangeSet other) { return other.contains(myValue) ? Empty.EMPTY : this; }
subtract
250,153
LongRangeSet (@NotNull LongRangeSet other) { return other.contains(myValue) ? this : Empty.EMPTY; }
meet
250,154
long () { return myValue; }
min
250,155
long () { return myValue; }
max
250,156
Long () { return myValue; }
getConstantValue
250,157
LongRangeSet (@NotNull LongRangeSet other) { if (other.isEmpty() || other == this) return this; if (other.contains(myValue)) return other; if (other instanceof Point) { long value1 = Math.min(myValue, ((Point)other).myValue); long value2 = Math.max(myValue, ((Point)other).myValue); return value1 + 1 == value2 ? range(v...
join
250,158
boolean (LongRangeSet other) { return other.contains(myValue); }
intersects
250,159
boolean (long value) { return myValue == value; }
contains
250,160
boolean (@NotNull LongRangeSet other) { return other.isEmpty() || equals(other); }
contains
250,161
LongRangeSet (LongRangeType lrType) { return myValue >= 0 || myValue == lrType.min() ? this : point(-myValue); }
abs
250,162
LongRangeSet (LongRangeType lrType) { return myValue == lrType.min() ? this : point(-myValue); }
negate
250,163
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (other.isEmpty()) return other; if (other instanceof Point) { long res = myValue + ((Point)other).myValue; return point(lrType.cast(res)); } return other.plus(this, lrType); }
plus
250,164
LongRangeSet (LongRangeSet multiplier, LongRangeType lrType) { if (multiplier.isEmpty()) return multiplier; if (myValue == 0) return this; if (myValue == 1) return multiplier; if (myValue == -1) return multiplier.negate(lrType); if (multiplier instanceof Point) { long val = ((Point)multiplier).myValue; long res = myVal...
mul
250,165
LongRangeSet (LongRangeSet divisor) { if (divisor.isEmpty() || divisor.equals(ZERO)) return empty(); if (myValue == 0) return this; if (divisor instanceof Point) { return LongRangeSet.point(myValue % ((Point)divisor).myValue); } if (myValue != Long.MIN_VALUE) { long abs = Math.abs(myValue); if (!divisor.intersects(Long...
mod
250,166
LongStream () { return LongStream.of(myValue); }
stream
250,167
List<LongRangeSet> () { return Collections.singletonList(this); }
asRanges
250,168
int () { return Long.hashCode(myValue); }
hashCode
250,169
boolean (Object o) { if (o == this) return true; return o instanceof Point && myValue == ((Point)o).myValue; }
equals
250,170
String () { return "{" + formatNumber(myValue) + "}"; }
toString
250,171
String (@NotNull LongRangeSet fullTypeRange) { if (fullTypeRange.min() == myFrom) { if (fullTypeRange.max() == myTo) { return InspectionsBundle.message("long.range.set.presentation.any"); } return "<= " + LongRangeSet.formatNumber(myTo); } else if (fullTypeRange.max() == myTo) { return ">= " + LongRangeSet.formatNumber...
getPresentationText
250,172
boolean (long cutoff) { long diff = myTo - myFrom; return diff < 0 || diff >= cutoff; }
isCardinalityBigger
250,173
LongRangeSet (@NotNull LongRangeSet other) { if (other.isEmpty()) return this; if (other == this) return Empty.EMPTY; if (other instanceof Point) { long value = ((Point)other).myValue; if (value < myFrom || value > myTo) return this; if (value == myFrom) return range(myFrom + 1, myTo); if (value == myTo) return range(m...
subtract
250,174
LongRangeSet (@NotNull LongRangeSet other) { if (other == this) return this; if (other.isEmpty()) return other; if ((other instanceof ModRange && !(this instanceof ModRange)) || other instanceof Point) { return other.meet(this); } if (other instanceof Range) { long from = ((Range)other).myFrom; long to = ((Range)other)...
meet
250,175
LongRangeSet (@NotNull LongRangeSet other) { if (other.isEmpty() || other == this) return this; if (other instanceof Point) { return other.join(this); } if (other instanceof Range) { if (other.min() <= max() && min() <= other.max() || (other.max() < min() && other.max() + 1 == min()) || (other.min() > max() && max() + ...
join
250,176
long () { return myFrom; }
min
250,177
long () { return myTo; }
max
250,178
boolean (LongRangeSet other) { if (other.isEmpty()) return false; if (other instanceof RangeSet) { long[] otherRanges = ((RangeSet)other).myRanges; for (int i = 0; i < otherRanges.length && otherRanges[i] <= myTo; i += 2) { if (myTo >= otherRanges[i] && myFrom <= otherRanges[i + 1]) return true; } return false; } retur...
intersects
250,179
boolean (long value) { return myFrom <= value && myTo >= value; }
contains
250,180
boolean (@NotNull LongRangeSet other) { return other.isEmpty() || other.min() >= myFrom && other.max() <= myTo; }
contains
250,181
LongRangeSet (LongRangeType lrType) { if (myFrom >= 0) return this; long minValue = lrType.min(); long low = myFrom, hi = myTo; if (low <= minValue) { low = minValue + 1; } if (myTo <= 0) { hi = -low; low = -myTo; } else { hi = Math.max(-low, hi); low = 0; } if (low > hi) { return lrType.fullRange(); } if (myFrom <= mi...
abs
250,182
LongRangeSet (LongRangeType lrType) { long minValue = lrType.min(); if (myFrom <= minValue) { if (myTo >= lrType.max()) { return lrType.fullRange(); } return new RangeSet(new long[]{minValue, minValue, -myTo, -(minValue + 1)}); } return new Range(-myTo, -myFrom); }
negate
250,183
LongRangeSet (LongRangeSet other, LongRangeType lrType) { if (other.isEmpty()) return other; if (equals(lrType.fullRange())) return this; if (other instanceof Point || other instanceof Range || (other instanceof RangeSet && ((RangeSet)other).myRanges.length > 6)) { return plus(myFrom, myTo, other.min(), other.max(), lr...
plus
250,184
LongRangeSet (long from1, long to1, long from2, long to2, LongRangeType lrType) { long len1 = to1 - from1; // may overflow long len2 = to2 - from2; // may overflow if ((len1 < 0 && len2 < 0) || ((len1 < 0 || len2 < 0) && len1 + len2 + 1 >= 0)) { // total length more than 2^64 return lrType.fullRange(); } long from = fr...
plus
250,185
LongRangeSet (LongRangeSet divisor) { if (divisor.isEmpty() || divisor.equals(Point.ZERO)) return empty(); if (divisor instanceof Point && ((Point)divisor).myValue == Long.MIN_VALUE) { return this.contains(Long.MIN_VALUE) ? this.subtract(divisor).join(Point.ZERO) : this; } if (divisor.contains(Long.MIN_VALUE)) { return...
mod
250,186
LongRangeSet () { if(contains(0)) return this; if(min() > 0) return range(0, max()); return range(min(), 0); }
possibleMod
250,187
LongStream () { return LongStream.rangeClosed(myFrom, myTo); }
stream
250,188
List<LongRangeSet> () { return Collections.singletonList(this); }
asRanges
250,189
int () { return Long.hashCode(myFrom) * 1337 + Long.hashCode(myTo); }
hashCode
250,190
boolean (Object o) { if (o == this) return true; return o != null && o.getClass() == getClass() && myFrom == ((Range)o).myFrom && myTo == ((Range)o).myTo; }
equals
250,191
String (@NotNull LongRangeSet fullTypeRange) { fullTypeRange = modRange(fullTypeRange.min(), fullTypeRange.max(), myMod, myBits); String prefix = null; if (fullTypeRange.min() == myFrom) { prefix = fullTypeRange.max() == myTo ? "" : "<= " + LongRangeSet.formatNumber(myTo); } else if (fullTypeRange.max() == myTo) { pref...
getPresentationText
250,192
boolean (long cutoff) { long bottom = myFrom - 1 - remainder(myFrom - 1, myMod) + myMod; long top = myTo - remainder(myTo, myMod); if (bottom >= myFrom && top > bottom && myTo >= top) { int count = Long.bitCount(myBits); long wholeCount = (top / myMod - bottom / myMod) * count; if (wholeCount < 0 || wholeCount > cutoff...
isCardinalityBigger
250,193
boolean (long value) { return super.contains(value) && isSet(myBits, remainder(value, myMod)); }
contains
250,194
LongRangeSet (@NotNull LongRangeSet other) { if (other instanceof Point p) { if (p.myValue == myFrom) { return modRange(myFrom + 1, myTo, myMod, myBits); } if (p.myValue == myTo) { return modRange(myFrom, myTo - 1, myMod, myBits); } } if (other instanceof Range r && !(other instanceof ModRange)) { if (r.myFrom <= myFro...
subtract
250,195
LongRangeSet (@NotNull LongRangeSet other) { LongRangeSet intersection = super.meet(other); if (intersection instanceof RangeSet) { long min = intersection.min(); long max = intersection.max(); long diff = max - min; if (diff > 0 && diff < Long.SIZE) { for (byte newMod = (byte)(diff + 1); newMod <= Long.SIZE; newMod++)...
meet
250,196
boolean (LongRangeSet other) { if (other instanceof Point) { return contains(((Point)other).myValue); } if (other instanceof ModRange modRange) { int lcm = lcm(modRange.myMod); if (lcm <= Long.SIZE && (modRange.widenBits(lcm) & widenBits(lcm)) == 0) return false; } long[] otherRanges = other.asRangeArray(); for (int i ...
intersects
250,197
LongRangeSet (@NotNull LongRangeSet other) { if (other instanceof ModRange modRange) { int lcm = lcm(modRange.myMod); if (lcm <= Long.SIZE) { long bits = widenBits(lcm) | modRange.widenBits(lcm); if (myTo >= modRange.myFrom && myFrom <= modRange.myTo || myTo < modRange.myFrom && modRange(myTo + 1, modRange.myFrom - 1, ...
join
250,198
boolean (@NotNull LongRangeSet other) { if (other instanceof ModRange modRange) { if (modRange.myFrom < myFrom || modRange.myTo > myTo) return false; int lcm = lcm(modRange.myMod); if (lcm <= Long.SIZE) { return (~widenBits(lcm) & modRange.widenBits(lcm)) == 0; } } long[] ranges = other.asRangeArray(); for (int i = 0; ...
contains
250,199
LongRangeSet (LongRangeType lrType) { LongRangeSet negated = super.negate(lrType); if (negated instanceof Range) { // Leave 0 at the place, reverse the rest long reverse = Long.reverse(myBits & -2); long negatedBits = (myMod == Long.SIZE ? reverse << 1 : reverse >>> (Long.SIZE - myMod - 1)) | (myBits & 1); return modRa...
negate