dart_interval 0.1.3 copy "dart_interval: ^0.1.3" to clipboard
dart_interval: ^0.1.3 copied to clipboard

This library provides data structure and operations for intervals in Dart.

Language: English | Chinese

dart_interval #

Build Status

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

or add this to your project's pubspec.yml:

dependencies:
  dart_interval: ^0.1.1

Feature #

  • Interval - The interval data structure.
  • IntervalSet - The interval merging.
  • Interval & Interval - The interval intersection calculation
  • Interval | Interval - The interval union calculation

Examples #

Usage #

Create a Interval: #

import 'package:dart_interval/dart_interval.dart';

final v1 = Interval.between(1, 3, lowerClosed: false, upperClosed: false);

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]

Interval intersection calculation: #

print(v1 & v2);
// output: [2, 3]

Interval union calculation: #

print(v1 | v2);
// output: [1, 5]

or

print(IntervalSet([v1, v2]));
// output: [1, 5]
2
likes
130
pub points
0%
popularity

Publisher

verified publisherfxcdev.com

This library provides data structure and operations for intervals in Dart.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on dart_interval