This library provides data structure and operations for intervals in Dart.
Depend on it
Run this command:
With Dart:
dart pub add dart_intervalor add this to your project's pubspec.yml:
dependencies:
dart_interval: ^0.1.1Interval- The interval data structure.IntervalSet- The interval merging.Interval & Interval- The interval intersection calculationInterval | Interval- The interval union calculation
- Simple example - Api example.
import 'package:dart_interval/dart_interval.dart';
final v1 = Interval.between(1, 3, lowerClosed: false, upperClosed: false);final v1 = Interval.between(1, 3);
final v2 = Interval.between(2, 5);
final v3 = Interval.between(7, 9);
final set = IntervalSet([v1, v2, v3]);
print(set);
// output: [1, 5],[7, 9]print(v1 & v2);
// output: [2, 3]print(v1 | v2);
// output: [1, 5]or
print(IntervalSet([v1, v2]));
// output: [1, 5]