Skip to content

Commit 79a4698

Browse files
committed
Update constraints, lints and format.
1 parent 2130a1a commit 79a4698

13 files changed

+203
-154
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.3.0
2+
3+
- Updated SDK constraint, lints and format.
4+
15
## 2.2.1
26

37
- Updated and fixed lints.

lib/bit_array.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
library bit_array;
2-
31
import 'dart:collection';
42
import 'dart:math' as math;
53
import 'dart:typed_data';

lib/src/bit_array.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class BitArray extends BitSet {
3333
if (list.lengthInBytes % 4 != 0) {
3434
throw FormatException('Uint8List length must be a multiplication of 4');
3535
}
36-
final data =
37-
list.buffer.asUint32List(list.offsetInBytes, list.lengthInBytes >> 2);
36+
final data = list.buffer.asUint32List(
37+
list.offsetInBytes,
38+
list.lengthInBytes >> 2,
39+
);
3840
return BitArray._(data);
3941
}
4042

@@ -94,9 +96,10 @@ class BitArray extends BitSet {
9496

9597
/// The number of bits set to true.
9698
@override
97-
int get cardinality => _data.buffer
98-
.asUint8List()
99-
.fold(0, (sum, value) => sum + _cardinalityBitCounts[value]);
99+
int get cardinality => _data.buffer.asUint8List().fold(
100+
0,
101+
(sum, value) => sum + _cardinalityBitCounts[value],
102+
);
100103

101104
/// Whether the [BitArray] is empty == has only zero values.
102105
bool get isEmpty {
@@ -294,7 +297,7 @@ class _IntIterator implements Iterator<int> {
294297
int _cursorMask = 1;
295298

296299
_IntIterator(this._buffer, this._length, this._matchValue)
297-
: _skipMatch = _matchValue ? 0x00 : 0xffffffff;
300+
: _skipMatch = _matchValue ? 0x00 : 0xffffffff;
298301

299302
@override
300303
int get current => _current;

lib/src/bit_counter.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class BitCounter {
117117
for (var i = _bits.length; i < shiftLeft; i++) {
118118
_bits.add(BitArray(_length));
119119
}
120-
for (var pos = shiftLeft;; pos++) {
120+
for (var pos = shiftLeft; ; pos++) {
121121
BitArray counter;
122122
if (_bits.length == pos) {
123123
counter = BitArray(_length);
@@ -233,7 +233,8 @@ class BitCounter {
233233
void max(BitCounter other) {
234234
if (_length != other._length) {
235235
throw ArgumentError(
236-
'Length does not match: $_length != ${other._length}');
236+
'Length does not match: $_length != ${other._length}',
237+
);
237238
}
238239
if (bitLength == 0) {
239240
_bits.addAll(other._bits.map((a) => a.clone()));
@@ -269,7 +270,8 @@ class BitCounter {
269270
void min(BitCounter other) {
270271
if (_length != other._length) {
271272
throw ArgumentError(
272-
'Length does not match: $_length != ${other._length}');
273+
'Length does not match: $_length != ${other._length}',
274+
);
273275
}
274276
if (bitLength == 0) {
275277
return;

lib/src/bit_set.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ abstract class BitSet {
4848
@override
4949
int get hashCode =>
5050
asUint32Iterable().fold(
51-
0, (int previousValue, element) => previousValue ^ element.hashCode) ^
51+
0,
52+
(int previousValue, element) => previousValue ^ element.hashCode,
53+
) ^
5254
length.hashCode;
5355
}
5456

lib/src/composite_counter.dart

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ class CompositeCounter {
2727
final int _offsetMask;
2828

2929
CompositeCounter({this.chunkBits = 16, List<BitCounterChunk>? chunks})
30-
: _chunkLength = (1 << chunkBits),
31-
_indexMask = (1 << chunkBits) - 1,
32-
_offsetMask = ~((1 << chunkBits) - 1),
33-
chunks = chunks ?? <BitCounterChunk>[];
30+
: _chunkLength = (1 << chunkBits),
31+
_indexMask = (1 << chunkBits) - 1,
32+
_offsetMask = ~((1 << chunkBits) - 1),
33+
chunks = chunks ?? <BitCounterChunk>[];
3434

3535
/// The maximum number of bits required to store the value of the counter.
3636
int get bitLength =>
@@ -86,17 +86,19 @@ class CompositeCounter {
8686
CompositeCounter multiply(int value) {
8787
return CompositeCounter(
8888
chunkBits: chunkBits,
89-
chunks: chunks
90-
.map((c) => BitCounterChunk(c.offset, c.bitCounter * value))
91-
.toList(),
89+
chunks:
90+
chunks
91+
.map((c) => BitCounterChunk(c.offset, c.bitCounter * value))
92+
.toList(),
9293
);
9394
}
9495

9596
/// Multiply this instance with [counter] and return the result.
9697
CompositeCounter multiplyWithCounter(CompositeCounter counter) {
9798
if (counter.chunkBits != chunkBits) {
9899
throw StateError(
99-
'Only counters with the same chunkBits can be multiplied');
100+
'Only counters with the same chunkBits can be multiplied',
101+
);
100102
}
101103
final result = CompositeCounter(chunkBits: counter.chunkBits);
102104
for (var bcc in counter.chunks) {
@@ -150,12 +152,14 @@ class CompositeCounter {
150152
/// current [CompositeCounter()] has a value larger or equal to [minValue].
151153
CompositeSet toMask({int minValue = 1}) {
152154
return CompositeSet(
153-
chunkBits: chunkBits,
154-
chunks: chunks.expand<BitSetChunk>((c) {
155-
final set = c.bitCounter.toMask(minValue: minValue);
156-
if (set.isEmpty) return [];
157-
return [BitSetChunk(c.offset, set)];
158-
}).toList());
155+
chunkBits: chunkBits,
156+
chunks:
157+
chunks.expand<BitSetChunk>((c) {
158+
final set = c.bitCounter.toMask(minValue: minValue);
159+
if (set.isEmpty) return [];
160+
return [BitSetChunk(c.offset, set)];
161+
}).toList(),
162+
);
159163
}
160164

161165
/// Updates the values to the maximum of the pairwise values with [other].
@@ -228,10 +232,15 @@ class CompositeCounter {
228232
CompositeCounter clone({int shiftRight = 0}) {
229233
return CompositeCounter(
230234
chunkBits: chunkBits,
231-
chunks: chunks
232-
.map((c) => BitCounterChunk(
233-
c.offset, c.bitCounter.clone(shiftRight: shiftRight)))
234-
.toList(),
235+
chunks:
236+
chunks
237+
.map(
238+
(c) => BitCounterChunk(
239+
c.offset,
240+
c.bitCounter.clone(shiftRight: shiftRight),
241+
),
242+
)
243+
.toList(),
235244
);
236245
}
237246

lib/src/composite_set.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class CompositeSet extends BitSet {
4242
final int _offsetMask;
4343

4444
CompositeSet({this.chunkBits = 16, List<BitSetChunk>? chunks})
45-
: _chunkLength = (1 << chunkBits),
46-
_indexMask = (1 << chunkBits) - 1,
47-
_offsetMask = ~((1 << chunkBits) - 1),
48-
chunks = chunks ?? <BitSetChunk>[];
45+
: _chunkLength = (1 << chunkBits),
46+
_indexMask = (1 << chunkBits) - 1,
47+
_offsetMask = ~((1 << chunkBits) - 1),
48+
chunks = chunks ?? <BitSetChunk>[];
4949

5050
@override
5151
bool operator [](int index) {
@@ -153,9 +153,10 @@ class CompositeSet extends BitSet {
153153
CompositeSet clone() {
154154
return CompositeSet(
155155
chunkBits: chunkBits,
156-
chunks: chunks
157-
.map((bsc) => BitSetChunk(bsc.offset, bsc.bitSet.clone()))
158-
.toList(),
156+
chunks:
157+
chunks
158+
.map((bsc) => BitSetChunk(bsc.offset, bsc.bitSet.clone()))
159+
.toList(),
159160
);
160161
}
161162

pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: bit_array
22
description: >
33
A bit array (also known as BitMap, BitSet, BitString, or BitVector)
44
is an array data structure that compactly stores bits.
5-
version: 2.2.1
5+
version: 2.3.0
66
homepage: https://github.com/isoos/bit_array
77
topics:
88
- bitarray
@@ -11,11 +11,11 @@ topics:
1111
- bitset
1212

1313
environment:
14-
sdk: '>=3.0.0 <4.0.0'
14+
sdk: '^3.7.0'
1515

1616
#dependencies:
1717
#
1818

1919
dev_dependencies:
20-
lints: ^4.0.0
20+
lints: ^5.0.0
2121
test: ^1.0.0

test/bit_array_test.dart

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ void main() {
6161
expect(array[15], isFalse);
6262
expect(array.cardinality, 266667);
6363
expect(array.asIntIterable().length, 266667);
64-
expect(array.asIntIterable().where((i) => i < 40).toList(),
65-
[3, 6, 9, 12, 18, 21, 24, 27, 33, 36, 39]);
64+
expect(array.asIntIterable().where((i) => i < 40).toList(), [
65+
3, 6, 9, 12, 18, 21, //
66+
24, 27, 33, 36, 39,
67+
]);
6668
});
6769

6870
test('packing and unpacking', () {
@@ -160,46 +162,54 @@ void main() {
160162

161163
test('and', () {
162164
expect(
163-
(array & list).toBinaryString(),
164-
'0000000000000100000000000000000000000000000000000000000000000000'
165-
'0000000000000000000000000000000000000000000000000000000000000000');
165+
(array & list).toBinaryString(),
166+
'0000000000000100000000000000000000000000000000000000000000000000'
167+
'0000000000000000000000000000000000000000000000000000000000000000',
168+
);
166169
expect(
167-
(array & range).toBinaryString(),
168-
'0000000000000000000000000000000000000000000000000000000000000000'
169-
'0000000000000000000000000000000000000000000000000100000000000000');
170+
(array & range).toBinaryString(),
171+
'0000000000000000000000000000000000000000000000000000000000000000'
172+
'0000000000000000000000000000000000000000000000000100000000000000',
173+
);
170174
});
171175

172176
test('andNot', () {
173177
expect(
174-
(array % list).toBinaryString(),
175-
'0000000000000000000000000000000000000000000000000000000000000000'
176-
'0000000000000000000000000000000000000000000000000100000000000000');
178+
(array % list).toBinaryString(),
179+
'0000000000000000000000000000000000000000000000000000000000000000'
180+
'0000000000000000000000000000000000000000000000000100000000000000',
181+
);
177182
expect(
178-
(array % range).toBinaryString(),
179-
'0000000000000100000000000000000000000000000000000000000000000000'
180-
'0000000000000000000000000000000000000000000000000000000000000000');
183+
(array % range).toBinaryString(),
184+
'0000000000000100000000000000000000000000000000000000000000000000'
185+
'0000000000000000000000000000000000000000000000000000000000000000',
186+
);
181187
});
182188

183189
test('or', () {
184190
expect(
185-
(array | list).toBinaryString(),
186-
'0000000000000100000000000000000001000000000000000000000000000000'
187-
'0000000000000000000000000000000000000000000000000100000000000000');
191+
(array | list).toBinaryString(),
192+
'0000000000000100000000000000000001000000000000000000000000000000'
193+
'0000000000000000000000000000000000000000000000000100000000000000',
194+
);
188195
expect(
189-
(array | range).toBinaryString(),
190-
'0000000000000100000000000000000000000000000000000000000000000000'
191-
'0000000000000000000000000000000000000000000000111100000000000000');
196+
(array | range).toBinaryString(),
197+
'0000000000000100000000000000000000000000000000000000000000000000'
198+
'0000000000000000000000000000000000000000000000111100000000000000',
199+
);
192200
});
193201

194202
test('xor', () {
195203
expect(
196-
(array ^ list).toBinaryString(),
197-
'0000000000000000000000000000000001000000000000000000000000000000'
198-
'0000000000000000000000000000000000000000000000000100000000000000');
204+
(array ^ list).toBinaryString(),
205+
'0000000000000000000000000000000001000000000000000000000000000000'
206+
'0000000000000000000000000000000000000000000000000100000000000000',
207+
);
199208
expect(
200-
(array ^ range).toBinaryString(),
201-
'0000000000000100000000000000000000000000000000000000000000000000'
202-
'0000000000000000000000000000000000000000000000111000000000000000');
209+
(array ^ range).toBinaryString(),
210+
'0000000000000100000000000000000000000000000000000000000000000000'
211+
'0000000000000000000000000000000000000000000000111000000000000000',
212+
);
203213
});
204214
});
205215
}

0 commit comments

Comments
 (0)