circular_buffer 0.12.0 copy "circular_buffer: ^0.12.0" to clipboard
circular_buffer: ^0.12.0 copied to clipboard

A Dart Circular Buffer container based on List with a fixed capacity.

example/main.dart

import 'package:circular_buffer/circular_buffer.dart';

void main() {
  final cb = CircularBuffer<int>(5);

  final list = <int>[4, 5, 1, -3, 8, 2, 6, 7, 4, 5];
  var sum = 0;
  double mean;
  for (final a in list) {
    final first = cb.isFilled ? cb.first : 0;
    cb.add(a);
    sum += cb.last - first;

    mean = sum.toDouble() / cb.length;

    // ignore: avoid_print
    print('Inserting $a:\tsum=$sum\tmean=$mean');
  }
}
4
likes
160
pub points
89%
popularity

Publisher

unverified uploader

A Dart Circular Buffer container based on List with a fixed capacity.

Repository

Documentation

Documentation
API reference

License

MIT (license)

More

Packages that depend on circular_buffer