Skip to main content

interval_skip_list 0.1.0 copy "interval_skip_list: ^0.1.0" to clipboard
interval_skip_list: ^0.1.0 copied to clipboard

Dart 1 only

This data structure maps intervals to values and allows you to find all intervals that contain an index in O(ln(n)), where n is the number of intervals stored.

example/interval_skip_list.dart

// Copyright (c) 2015, <your name>. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

library interval_skip_list.example;

import 'package:interval_skip_list/interval_skip_list.dart';

main() {
  final list =
      new IntervalSkipList(minIndex: -0x80000000, maxIndex: 0x7FFFFFFF);

  list.insert('a', 2, 7);
  list.insert('b', 1, 5);
  list.insert('c', 8, 8);

  print(list.findContaining([1]));
  // ['b']
  print(list.findContaining([2]));
  // ['b', 'a']
  print(list.findContaining([8]));
  // ['c']

  list.remove('b');

  print(list.findContaining([2]));
  // ['a']
}
0
likes
40
points
13
downloads

Publisher

unverified uploader

Weekly Downloads

This data structure maps intervals to values and allows you to find all intervals that contain an index in O(ln(n)), where n is the number of intervals stored.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

meta

More

Packages that depend on interval_skip_list