lists
v1.0.1Collection of the lists (BitList, FilledList, GroupedRangeList, ListPointer, RangeList, SparseBoolList, SparseList, StepList, WrappedList).
Package archive: https://pubdev.letsnova.ru/api/archives/lists/1.0.1.tar.gz
Install
dart pub add listsReadme
lists
This package is no longer supported because it was flagged by Google Dart developers as being published by an unknown person.
Publisher Unknown.
As a normal person, I believe that hardly anyone would want to use software from unknown publishers.
Collection of the lists (BitList, FilledList, GroupedRangeList, ListPointer, RangeList, SparseBoolList, SparseList, StepList, WrappedList).
Version: 1.0.1
import 'package:lists/lists.dart';
void main() {
bitList();
filledList();
rangeList();
sparseBoolList();
sparseList();
stepList();
wrappedList();
}
void bitList() {
// The bit state list with 65536 elements
// Real size of the list (in memory) 30 times less
// Exact size 2185 elements of 'Smi' values
var list = BitList(65536);
list.set(32767);
print(list.get(32767));
// The list with 65536 elements set to true
list = BitList(65536, true);
print(list.get(32767));
// The list with 1073741824 elements
list = BitList(1073741824);
}
void filledList() {
// The read only list with 40 values of "="
var list = FilledList<String>(40, '=');
print('${list.join()}');
// The list with 10000000000000 values of "hello"
list = FilledList<String>(10000000000000, 'hello');
}
void rangeList() {
// The values from 0 to 10
var list = RangeList(0, 10);
print("${list.join(", ")}");
// The same values in reversed order
final reversed = list.reversed;
print("${reversed.join(", ")}");
// The same list with step 2
final list2 = list.toStepList(2);
print("${list2.join(", ")}");
// The values from -10000000000000 to 10000000000000
list = RangeList(10000000000000, 10000000000000);
}
void sparseBoolList() {
// Really big size
final length = 2 * 1024 * 1024 * 1024;
final list = SparseBoolList.fixed(length);
var groupCount = 0;
var offset = 0;
print('SparseBoolList: ${_format(length)} length.');
final sw = Stopwatch();
sw.start();
while (true) {
final size = 128 * 1024;
list.setGroup(GroupedRangeList(offset, offset + size, true));
offset += size + 128 * 1024;
groupCount++;
if (offset >= length) {
break;
}
}
//
sw.stop();
var elapsed = sw.elapsedMilliseconds / 1000;
print('SparseBoolList: ${_format(groupCount)} groups added in $elapsed sec.');
//
var accessed = 0;
//
sw.reset();
sw.start();
for (var i = 0; i < length; i += 100) {
// ignore: unused_local_variable
final x = list[i];
accessed++;
}
sw.stop();
elapsed = sw.elapsedMilliseconds / 1000;
print(
'SparseBoolList: ${_format(accessed)} elements accessed in $elapsed sec.');
}
void sparseList() {
// Count is 50000 elements
final count = 50000;
final list = SparseList();
var offset = 0;
final sw = Stopwatch();
sw.start();
for (var i = 0; i < count; i++) {
offset += 100;
final size = 100;
//list.addGroup(_grp(offset, offset + size, i));
list.addGroup(GroupedRangeList(offset, offset + size, i));
offset += size;
}
sw.stop();
var elapsed = sw.elapsedMilliseconds / 1000;
print('SparseList: ${_format(count)} groups added in $elapsed sec.');
// Access all elements
sw.reset();
sw.start();
final length = list.length;
for (var i = 0; i < length; i++) {
// ignore: unused_local_variable
final x = list[i];
}
sw.stop();
elapsed = sw.elapsedMilliseconds / 1000;
print('SparseList: ${_format(length)} elements accessed in $elapsed sec.');
}
void stepList() {
// The values from 0 to 10
var list = StepList(0, 10);
print("${list.join(", ")}");
// The values from 10 to 0
list = StepList(10, 0);
print("${list.join(", ")}");
// The values from 0 to 10 with step 2
list = StepList(0, 10, 2);
print("${list.join(", ")}");
// The values from 10 to 0 with step -2
list = StepList(10, 0, -2);
print("${list.join(", ")}");
// The values from 0 to 255 with step 64
const MIN_BYTE = 0;
const MAX_BYTE = 255;
list = StepList(MIN_BYTE, MAX_BYTE, (MAX_BYTE >> 2) + 1);
print("${list.join(", ")}");
// The values from -10000000000000 to 10000000000000 with step 1
list = StepList(-10000000000000, 10000000000000);
}
void wrappedList() {
// The read only wrapper for list
final source = [0, 1, 2, 3];
final list = WrappedList<int>(source);
try {
list[0] = 0;
} catch (e) {
print('$e');
}
try {
list.length = 0;
} catch (e) {
print('$e');
}
}
String _format(int number) {
final string = number.toString();
final length = string.length;
final list = <String>[];
var count = 0;
for (var i = length - 1; i >= 0; i--) {
list.add(string[i]);
if (count++ == 2) {
list.add(' ');
count = 0;
}
}
return list.reversed.join();
}
Changelog
1.0.1
- This package is no longer supported because it was flagged by Google Dart developers as being published by an unknown person. Publisher Unknown. As a normal person, I believe that hardly anyone would want to use software from unknown publishers.
1.0.0
- The source code has been migrated to null safety. Thanks to the author of this work, Dmitry (https://github.com/kelegorm).
0.1.6
- Added hash code support in
RangeListimplementation
0.1.5
- Fixed bug in
SparseList.setGroup()when the group key is equal to the list default value
0.1.4
- Source code changed to be more pedantic
0.1.3
- Minor changes
0.1.2
- Source code changed to be more pedantic
0.1.1
- Added parameter
equalsto constructorSparseList()to specify comparison function of complex data structures - Source code changed to be more pedantic
0.1.0
- Algorithm in
SparseListhas been reworked
0.0.23
- Fixed strong-mode cast errors.
- Added
incrementtoListPointer, which is a type-safe way to increase the pointer.
0.0.22
- Added
strong_modeoption
0.0.21
- Added
ListPointerwhich can be used effectively when porting the programs written in the C language
0.0.20
- Added method
getAllSpace(RangeList range) => List<GroupedRangeList<E>>toSparseList<E>
0.0.19
- Added method
getAlignedGroups(RangeList range) => List<GroupedRangeList<E>>toSparseList<E>
0.0.18
- Fixed bug in
SparseList.getGroups()
0.0.17
- Added field
frozen => booltoSparseList<E> - Added method
freeze() => voidtoSparseList<E> SparseList<E>now can be frozen
0.0.16
- Fixed bug (change length of fixed list) in
SparseList.addGroup()
0.0.15
- Fixed bug (change length of fixed list) in
SparseList.removeValues() - Fixed bug (change length of fixed list) in
SparseList.trim()
0.0.14
- Added method
trim() => voidtoSparseList<E> - Fixed bug (decrease length) in
SparseList.removeValues() - Improved performance of modifications
SparseList<E>
0.0.12
- Fixed bug (decrease length) in
SparseList.removeValues()
0.0.11
- Fixed bug in
SparseList.removeValues()
0.0.10
- Improved performance of modifications
SparseList<E> - Removed limitations on the bounds of the range in
SparseList.removeValues()
0.0.9
- Added method
getIndexes() => Iterable<int>toSparseList<E>
0.0.8
- Added field
groups => List<GroupedRangeList<E>>toSparseList<E>
0.0.7
- Added field
end => inttoSparseList<E> - Added field
start => inttoSparseList<E>
0.0.6
- Added class
SparseBoolList - Modified method in
SparseList<E>fromgetGroups(RangeList range)togetGroups([RangeList range])
0.0.5
- Improved (up to 15%) the performance of the
SparseList.addGroup()when the group added to the end
0.0.4
- Added class
GroupedRangeList<E> - Added class
SparseList<E> - Added method
includes(RangeList other) => booltoRangeList - Added method
intersection(RangeList other) => RangeListtoRangeList - Added method
subtract(RangeList other) => List<RangeList>toRangeList - Added operator
+(RangeList other) => RangeListtoRangeList
