0 purchases
dart interval
Language: English | Chinese
dart_interval #
This library provides data structure and operations for intervals in Dart.
Installation #
Depend on it
Run this command:
With Dart:
dart pub add dart_interval
copied to clipboard
or add this to your project's pubspec.yml:
dependencies:
dart_interval: ^0.1.1
copied to clipboard
Feature #
Interval - The interval data structure.
IntervalSet - The interval merging.
Interval & Interval - The interval intersection calculation
Interval | Interval - The interval union calculation
Examples #
Simple example - Api example.
Usage #
Create a Interval: #
import 'package:dart_interval/dart_interval.dart';
final v1 = Interval.between(1, 3, lowerClosed: false, upperClosed: false);
copied to clipboard
Merge the intervals: #
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]
copied to clipboard
Interval intersection calculation: #
print(v1 & v2);
// output: [2, 3]
copied to clipboard
Interval union calculation: #
print(v1 | v2);
// output: [1, 5]
copied to clipboard
or
print(IntervalSet([v1, v2]));
// output: [1, 5]
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.