Skip to content

Commit

Permalink
Use the more efficient IntegerRange.of and IntegerRange.length co…
Browse files Browse the repository at this point in the history
…nstructors where possible.
  • Loading branch information
renggli committed Jan 25, 2024
1 parent 25c933b commit 7fad58d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/src/collection/bitlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ abstract class BitList extends ListBase<bool> {
/// function for each index.
factory BitList.generate(int length, bool Function(int index) generator,
{bool growable = false}) =>
BitList.of(IntegerRange(length).map(generator), growable: growable);
BitList.of(IntegerRange.length(length).map(generator),
growable: growable);

/// Constructs a new list from a given [Iterable] of booleans.
factory BitList.of(Iterable<bool> other, {bool growable = false}) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/graph/factory/random.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ extension RandomGraphFactoryExtension<V, E> on GraphFactory<V, E> {
}
if (probability > 0) {
final edges = isDirected
? IntegerRange(vertexCount).permutations(2)
: IntegerRange(vertexCount).combinations(2);
? IntegerRange.length(vertexCount).permutations(2)
: IntegerRange.length(vertexCount).combinations(2);
for (final edge in edges) {
if (random.nextDouble() < probability) {
builder.addEdgeIndex(edge[0], edge[1]);
Expand Down

0 comments on commit 7fad58d

Please sign in to comment.