Files
pipelines/app/third_party/xterm/lib/src/utils/lookup_table.dart
T
alan a6e04895ba Vendor pristine xterm.dart 4.0.0 under app/third_party/xterm
Unmodified copy of lib/, LICENSE (MIT), pubspec.yaml and CHANGELOG.md from
pub.dev xterm 4.0.0; the upstream README is kept as UPSTREAM_README.md.
Committed on its own so later patches are reviewable as diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 23:17:41 +00:00

35 lines
665 B
Dart

/// Fixed-size list based lookup table, optimized for small positive integer
/// keys.
class FastLookupTable<T> {
FastLookupTable(Map<int, T> data) {
var maxIndex = data.keys.first;
for (var key in data.keys) {
if (key > maxIndex) {
maxIndex = key;
}
}
_maxIndex = maxIndex;
_table = List<T?>.filled(maxIndex + 1, null);
for (var entry in data.entries) {
_table[entry.key] = entry.value;
}
}
late final List<T?> _table;
late final int _maxIndex;
T? operator [](int index) {
if (index > _maxIndex) {
return null;
}
return _table[index];
}
int get maxIndex => _maxIndex;
}