mirror of
https://gitlab.com/veilid/veilid.git
synced 2025-07-27 17:05:27 -04:00
fix overzealous gitignore and organize flutter a bit
This commit is contained in:
parent
019cb5fd79
commit
d244c1f6a5
9 changed files with 301 additions and 385 deletions
|
@ -123,59 +123,6 @@ extension DHTRecordDescriptorExt on DHTRecordDescriptor {
|
|||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
/// ValueSubkeyRange
|
||||
|
||||
@freezed
|
||||
class ValueSubkeyRange with _$ValueSubkeyRange {
|
||||
@Assert('low >= 0 && low <= high', 'range is invalid')
|
||||
const factory ValueSubkeyRange({
|
||||
required int low,
|
||||
required int high,
|
||||
}) = _ValueSubkeyRange;
|
||||
|
||||
factory ValueSubkeyRange.single(int val) =>
|
||||
ValueSubkeyRange(low: val, high: val);
|
||||
|
||||
factory ValueSubkeyRange.fromJson(dynamic json) =>
|
||||
_$ValueSubkeyRangeFromJson(json as Map<String, dynamic>);
|
||||
}
|
||||
|
||||
extension ValueSubkeyRangeExt on ValueSubkeyRange {
|
||||
bool contains(int v) => low <= v && v <= high;
|
||||
List<ValueSubkeyRange> remove(int v) {
|
||||
if (v < low || v > high) {
|
||||
return [this];
|
||||
}
|
||||
if (v == low) {
|
||||
if (v == high) {
|
||||
return [];
|
||||
} else {
|
||||
return [ValueSubkeyRange(low: v + 1, high: high)];
|
||||
}
|
||||
} else if (v == high) {
|
||||
return [ValueSubkeyRange(low: low, high: v - 1)];
|
||||
} else {
|
||||
return [
|
||||
ValueSubkeyRange(low: low, high: v - 1),
|
||||
ValueSubkeyRange(low: v + 1, high: high)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ListValueSubkeyRangeExt on List<ValueSubkeyRange> {
|
||||
bool containsSubkey(int v) => indexWhere((e) => e.contains(v)) != -1;
|
||||
List<ValueSubkeyRange> removeSubkey(int v) {
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (this[i].contains(v)) {
|
||||
return [...sublist(0, i), ...this[i].remove(v), ...sublist(i + 1)];
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
/// ValueData
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue