lookaround_iterator 1.0.0

Dart lookaround iterator

The LookaroundIterator class exposes a fixed number of elements in the past and future of the current iteration element.

// `it` is an iterator over a list of the numbers 1..10, currently
// pointing at `4`.
final it = new LookaroundIterator(
    new List.generate(10, (n) => n + 1).iterator,
    lookbehind: 2,
    lookahead: 3)
  ..moveNext()
  ..moveNext()
  ..moveNext()
  ..moveNext();

// Prints _2, 3, 4, 5, 6, 7_.
// Notice the negative start index and the inclusive range `<=`.
for (int i = -it.lookbehind; i <= it.lookahead; i++) {
  print(it[i]);
}

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  lookaround_iterator: "^1.0.0"

2. Install it

You can install packages from the command line:

$ pub get

Alternatively, your editor might support 'pub get'. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:lookaround_iterator/lookaround_iterator.dart';

Platforms

About

Provides an iterator class with lookbehind and lookahead buffer.

Author

Email philippschiffmann93@gmail.com Philipp Schiffmann

Homepage

github.com/pschiffmann/lookaround-iterator

Documentation

www.dartdocs.org/documentation/lookaround_iterator/1.0.0/

Uploader

philippschiffmann93@gmail.com

License

MIT

Published

Aug 13, 2017

Share