-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.dart
81 lines (65 loc) · 1.72 KB
/
utils.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import 'package:collection/collection.dart';
bool deepListEquals(List<List<int>> first, List<List<int>> second) {
if (first.length != second.length) {
return false;
}
for (var i = 0; i < first.length; i++) {
if (first[i].length != second[i].length) {
return false;
}
for (var j = 0; j < first[i].length; j++) {
if (first[i][j] != second[i][j]) {
return false;
}
}
}
return true;
}
class SortedList<E> extends DelegatingList<E> {
int Function(E a, E b)? _compareFunction;
List<E> get _listBase => super.toList();
SortedList([int Function(E a, E b)? compareFunction]) : super(<E>[]) {
this._compareFunction = compareFunction;
}
@override
void add(E value) {
var index = lowerBound(_listBase, value, compare: _compareFunction);
super.insert(index, value);
}
@override
void addAll(Iterable<E> iterable) {
_throwNotSupportedException();
}
@override
List<E> operator +(List<E> other) {
throw Exception('Cannot add two sorted lists.');
}
_throwNotSupportedException() {
throw Exception('Cannot insert element at a specific index in a sorted list.');
}
@deprecated
@override
void insert(int index, E element) {
_throwNotSupportedException();
}
@deprecated
@override
void insertAll(int index, Iterable<E> iterable) {
_throwNotSupportedException();
}
@deprecated
@override
void operator []=(int index, E value) {
_throwNotSupportedException();
}
@deprecated
@override
void setAll(int index, Iterable<E> iterable) {
_throwNotSupportedException();
}
@deprecated
@override
void setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) {
_throwNotSupportedException();
}
}