simple_sparse_list 0.1.1 copy "simple_sparse_list: ^0.1.1" to clipboard
simple_sparse_list: ^0.1.1 copied to clipboard

A simple and efficient implementation of an unmodifiable sparse list based on the binary search algorithm.

simple_sparse_list #

A simple and efficient implementation of an unmodifiable sparse list based on the binary search algorithm.

Version: 0.1.1

Pub Package GitHub Issues GitHub Forks GitHub Stars GitHub License

What is it and what is it for? #

This is a simple and efficient implementation of an unmodifiable sparse list based on the binary search algorithm.
A sparse list can be used to store and process large amounts of static data specified as a large number of ranges.
Using a sparse list allows to significantly reduce the amount of data storage.
The performance of data access operations is determined by the speed of binary search.

Possible applications are handling Unicode data in converters, matchers, parsers, validators, etc.

Sparse list example #

import 'package:simple_sparse_list/simple_sparse_list.dart';

void main(List<String> args) {
  _test(32);
  _test(48);
  _test(73);
  _test(100);
  _test(320);
  _test(0x10ffff);
}

final _data = [
  (48, 57, Letter.number),
  (65, 90, Letter.upperCase),
  (97, 122, Letter.lowerCase),
];

final _list = SparseList(_data, Letter.unknown, length: 0x10ffff);

void _test(int c) {
  final kind = _list[c];
  print('$c: $kind');
}

enum Letter { lowerCase, number, unknown, upperCase }

Output:

32: Letter.unknown
48: Letter.number
73: Letter.upperCase
100: Letter.lowerCase
320: Letter.unknown
1114111: Letter.unknown
0
likes
0
points
43k
downloads

Publisher

unverified uploader

Weekly Downloads

A simple and efficient implementation of an unmodifiable sparse list based on the binary search algorithm.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on simple_sparse_list