lists 0.0.23

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 62

lists

Collection of the lists (BitList, FilledList, GroupedRangeList, ListPointer, RangeList, SparseBoolList, SparseList, StepList, WrappedList).

Version: 0.0.21

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 = new BitList(65536);
  list.set(32767);
  print(list.get(32767));

  // The list with 65536 elements set to true
  list = new BitList(65536, true);
  print(list.get(32767));

  // The list with 1073741824 elements
  list = new BitList(1073741824);
}

void filledList() {
  // The read only list with 40 values of "="
  var list = new FilledList<String>(40, "=");
  print("${list.join()}");

  // The list with 10000000000000 values of "hello"
  list = new FilledList<String>(10000000000000, "hello");
}

void rangeList() {
  // The values from 0 to 10
  var list = new RangeList(0, 10);
  print("${list.join(", ")}");

  // The same values in reversed order
  var reversed = list.reversed;
  print("${reversed.join(", ")}");

  // The same list with step 2
  var list2 = list.toStepList(2);
  print("${list2.join(", ")}");

  //  The values from -10000000000000 to 10000000000000
  list = new RangeList(10000000000000, 10000000000000);
}

void sparseBoolList() {
  // Really big size
  var length = 2 * 1024 * 1024 * 1024;
  var list = new SparseBoolList(length: length);
  var groupCount = 0;
  var offset = 0;
  print("SparseBoolList: ${_format(length)} length.");
  var sw = new Stopwatch();
  sw.start();
  while (true) {
    var size = 128 * 1024;
    //list.addGroup(_grp(offset, offset + size, true));
    list.addGroup(new 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 acessed = 0;
  var elementCount = length / 10;
  //
  sw.reset();
  sw.start();
  for (var i = 0; i < length; i += 100) {
    var x = list[i];
    acessed++;
  }

  sw.stop();
  elapsed = (sw.elapsedMilliseconds / 1000);
  print("SparseBoolList: ${_format(acessed)} elements accessed in $elapsed sec."
      );
}

void sparseList() {
  // Count is 50000 elements
  var count = 50000;
  var list = new SparseList();
  var offset = 0;
  var sw = new Stopwatch();
  sw.start();
  for (var i = 0; i < count; i++) {
    offset += 100;
    var size = 100;
    //list.addGroup(_grp(offset, offset + size, i));
    list.addGroup(new 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();
  var length = list.length;
  for (var i = 0; i < length; i++) {
    var 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 = new StepList(0, 10);
  print("${list.join(", ")}");

  // The values from 10 to 0
  list = new StepList(10, 0);
  print("${list.join(", ")}");

  // The values from 0 to 10 with step 2
  list = new StepList(0, 10, 2);
  print("${list.join(", ")}");

  // The values from 10 to 0 with step -2
  list = new 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 = new StepList(MIN_BYTE, MAX_BYTE, (MAX_BYTE >> 2) + 1);
  print("${list.join(", ")}");

  // The values from -10000000000000 to 10000000000000 with step 1
  list = new StepList(-10000000000000, 10000000000000);
}

void wrappedList() {
  // The read only wrapper for list
  var source = [0, 1, 2, 3];
  var list = new WrappedList<int>(source);
  try {
    list[0] = 0;
  } catch (e, s) {
    print("$e");
  }

  try {
    list.length = 0;
  } catch (e, s) {
    print("$e");
  }
}

GroupedRangeList _grp(int start, int end, dynamic key) {
  return new GroupedRangeList(start, end, key);
}

String _format(int number) {
  var string = number.toString();
  var length = string.length;
  var 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();
}

0.0.23

  • Fixed strong-mode cast errors.
  • Added increment to ListPointer, which is a type-safe way to increase the pointer.

0.0.22

  • Added strong_mode option

0.0.21

  • Added ListPointer which can be used effectively when porting the programs written in the C language

0.0.20

  • Added method getAllSpace(RangeList range) => List<GroupedRangeList<E>> to SparseList<E>

0.0.19

  • Added method getAlignedGroups(RangeList range) => List<GroupedRangeList<E>> to SparseList<E>

0.0.18

  • Fixed bug in SparseList.getGroups()

0.0.17

  • Added field frozen => bool to SparseList<E>
  • Added method freeze() => void to SparseList<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() => void to SparseList<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> to SparseList<E>

0.0.8

  • Added field groups => List<GroupedRangeList<E>> to SparseList<E>

0.0.7

  • Added field end => int to SparseList<E>
  • Added field start => int to SparseList<E>

0.0.6

  • Added class SparseBoolList
  • Modified method in SparseList<E> from getGroups(RangeList range) to getGroups([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) => bool to RangeList
  • Added method intersection(RangeList other) => RangeList to RangeList
  • Added method subtract(RangeList other) => List<RangeList> to RangeList
  • Added operator +(RangeList other) => RangeList to RangeList

example/example.dart

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 = new BitList(65536);
  list.set(32767);
  print(list.get(32767));

  // The list with 65536 elements set to true
  list = new BitList(65536, true);
  print(list.get(32767));

  // The list with 1073741824 elements
  list = new BitList(1073741824);
}

void filledList() {
  // The read only list with 40 values of "="
  var list = new FilledList<String>(40, "=");
  print("${list.join()}");

  // The list with 10000000000000 values of "hello"
  list = new FilledList<String>(10000000000000, "hello");
}

void rangeList() {
  // The values from 0 to 10
  var list = new RangeList(0, 10);
  print("${list.join(", ")}");

  // The same values in reversed order
  var reversed = list.reversed;
  print("${reversed.join(", ")}");

  // The same list with step 2
  var list2 = list.toStepList(2);
  print("${list2.join(", ")}");

  //  The values from -10000000000000 to 10000000000000
  list = new RangeList(10000000000000, 10000000000000);
}

void sparseBoolList() {
  // Really big size
  var length = 2 * 1024 * 1024 * 1024;
  var list = new SparseBoolList(length: length);
  var groupCount = 0;
  var offset = 0;
  print("SparseBoolList: ${_format(length)} length.");
  var sw = new Stopwatch();
  sw.start();
  while (true) {
    var size = 128 * 1024;
    //list.addGroup(_grp(offset, offset + size, true));
    list.addGroup(new 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 acessed = 0;
  var elementCount = length / 10;
  //
  sw.reset();
  sw.start();
  for (var i = 0; i < length; i += 100) {
    var x = list[i];
    acessed++;
  }

  sw.stop();
  elapsed = (sw.elapsedMilliseconds / 1000);
  print(
      "SparseBoolList: ${_format(acessed)} elements accessed in $elapsed sec.");
}

void sparseList() {
  // Count is 50000 elements
  var count = 50000;
  var list = new SparseList();
  var offset = 0;
  var sw = new Stopwatch();
  sw.start();
  for (var i = 0; i < count; i++) {
    offset += 100;
    var size = 100;
    //list.addGroup(_grp(offset, offset + size, i));
    list.addGroup(new 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();
  var length = list.length;
  for (var i = 0; i < length; i++) {
    var 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 = new StepList(0, 10);
  print("${list.join(", ")}");

  // The values from 10 to 0
  list = new StepList(10, 0);
  print("${list.join(", ")}");

  // The values from 0 to 10 with step 2
  list = new StepList(0, 10, 2);
  print("${list.join(", ")}");

  // The values from 10 to 0 with step -2
  list = new 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 = new StepList(MIN_BYTE, MAX_BYTE, (MAX_BYTE >> 2) + 1);
  print("${list.join(", ")}");

  // The values from -10000000000000 to 10000000000000 with step 1
  list = new StepList(-10000000000000, 10000000000000);
}

void wrappedList() {
  // The read only wrapper for list
  var source = [0, 1, 2, 3];
  var list = new WrappedList<int>(source);
  try {
    list[0] = 0;
  } catch (e, s) {
    print("$e");
  }

  try {
    list.length = 0;
  } catch (e, s) {
    print("$e");
  }
}

GroupedRangeList _grp(int start, int end, dynamic key) {
  return new GroupedRangeList(start, end, key);
}

String _format(int number) {
  var string = number.toString();
  var length = string.length;
  var 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();
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  lists: ^0.0.23

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:lists/lists.dart';
  
Version Uploaded Documentation Archive
0.0.23 Jul 17, 2018 Go to the documentation of lists 0.0.23 Download lists 0.0.23 archive
0.0.22 Jun 6, 2017 Go to the documentation of lists 0.0.22 Download lists 0.0.22 archive
0.0.21 Feb 23, 2015 Go to the documentation of lists 0.0.21 Download lists 0.0.21 archive
0.0.20 Oct 4, 2014 Go to the documentation of lists 0.0.20 Download lists 0.0.20 archive
0.0.19 Sep 12, 2014 Go to the documentation of lists 0.0.19 Download lists 0.0.19 archive
0.0.18 Aug 28, 2014 Go to the documentation of lists 0.0.18 Download lists 0.0.18 archive
0.0.17 Aug 24, 2014 Go to the documentation of lists 0.0.17 Download lists 0.0.17 archive
0.0.16 Aug 20, 2014 Go to the documentation of lists 0.0.16 Download lists 0.0.16 archive
0.0.15 Aug 20, 2014 Go to the documentation of lists 0.0.15 Download lists 0.0.15 archive
0.0.14 Aug 20, 2014 Go to the documentation of lists 0.0.14 Download lists 0.0.14 archive

All 22 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
30
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
62
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:lists/lists.dart.

Health suggestions

Fix lib/src/sparse_list.dart. (-1.49 points)

Analysis of lib/src/sparse_list.dart reported 3 hints:

line 457 col 9: The value of the local variable 'insertAt' isn't used.

line 486 col 11: The value of the local variable 'start' isn't used.

line 487 col 11: The value of the local variable 'end' isn't used.

Fix lib/src/list_pointer.dart. (-0.50 points)

Analysis of lib/src/list_pointer.dart reported 1 hint:

line 106 col 17: Always override hashCode if overriding ==.

Fix lib/src/range_list.dart. (-0.50 points)

Analysis of lib/src/range_list.dart reported 1 hint:

line 35 col 17: Always override hashCode if overriding ==.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <3.0.0
Dev dependencies
build_tools any
test any