Initial commit

This commit is contained in:
toly
2023-04-16 10:28:45 +08:00
commit a1465d4a52
139 changed files with 5073 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
void main() {
foo4();
}
void foo1() {
List<int> numList = [1, 9, 9, 4, 3, 2, 8];
int second = numList[1];
print(second);
numList[3] = 6;
print(numList);
}
void foo2() {
List<int> numList = [1, 9, 9, 4, 3, 2, 8];
numList.add(10);
numList.insert(0, 49);
print(numList);
}
void foo3() {
List<int> numList = [1, 9, 9, 4, 3, 2, 8];
numList.removeAt(2);
numList.remove(3);
numList.removeLast();
print(numList);
}
void foo4() {
List<int> numList = [1, 9, 9, 4,];
for (int i = 0; i < numList.length; i++) {
int value = numList[i];
print("索引:$i, 元素值:$value");
}
for(int value in numList){
print("元素值:$value");
}
}

37
test/aggregation/map.dart Normal file
View File

@@ -0,0 +1,37 @@
void main() {
foo3();
}
void foo1() {
Map<int, String> numMap = {
0: 'zero',
1: 'one',
2: 'two',
};
print(numMap);
numMap.remove(1);
print(numMap);
}
void foo2() {
Map<int, String> numMap = {
0: 'zero',
1: 'one',
2: 'two',
};
numMap[3] = 'three';
numMap[4] = 'four';
print(numMap);
}
void foo3() {
Map<int, String> numMap = {
0: 'zero',
1: 'one',
2: 'two',
};
numMap.forEach((key, value) {
print("${key} = $value");
});
}

30
test/aggregation/set.dart Normal file
View File

@@ -0,0 +1,30 @@
void main() {
foo3();
}
void foo1() {
Set<int> numSet = {1, 9, 9, 4};
print(numSet);
}
void foo2() {
Set<int> numSet = {1, 9, 4};
numSet.add(10);
numSet.remove(9);
print(numSet);
}
void foo3() {
Set<int> a = {1, 9, 4};
Set<int> b = {1, 9, 3};
print(a.difference(b));// 差集
print(a.union(b)); // 并集
print(a.intersection(b)); // 交集
}
void foo4() {
Set<int> numSet = {1, 9, 4};
for(int value in numSet){
print("元素值:$value");
}
}