| Index: sdk/lib/_internal/pub_generated/lib/src/transcript.dart
|
| diff --git a/sdk/lib/_internal/pub_generated/lib/src/transcript.dart b/sdk/lib/_internal/pub_generated/lib/src/transcript.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..38702e135780e89293f80f8f789a4d6cd3e9f5a1
|
| --- /dev/null
|
| +++ b/sdk/lib/_internal/pub_generated/lib/src/transcript.dart
|
| @@ -0,0 +1,30 @@
|
| +library pub.transcript;
|
| +import 'dart:collection';
|
| +class Transcript<T> {
|
| + final int max;
|
| + int get discarded => _discarded;
|
| + int _discarded = 0;
|
| + final _oldest = new List<T>();
|
| + final _newest = new Queue<T>();
|
| + Transcript(this.max);
|
| + void add(T entry) {
|
| + if (discarded > 0) {
|
| + _newest.removeFirst();
|
| + _discarded++;
|
| + } else if (_newest.length == max) {
|
| + while (_newest.length > max ~/ 2) {
|
| + _oldest.add(_newest.removeFirst());
|
| + }
|
| + _newest.removeFirst();
|
| + _discarded++;
|
| + }
|
| + _newest.add(entry);
|
| + }
|
| + void forEach(void onEntry(T entry), [void onGap(int)]) {
|
| + if (_oldest.isNotEmpty) {
|
| + _oldest.forEach(onEntry);
|
| + if (onGap != null) onGap(discarded);
|
| + }
|
| + _newest.forEach(onEntry);
|
| + }
|
| +}
|
|
|