Dart base language – Set

A Set is a uniquely ordered queue of elements

loose

// var a = new Set();
// a.add('java');
// a.add('php');
// a.add('python');
// a.add('java');
// a.add('sql');
// a.add('swift');
// a.add('dart');
Copy the code

Strongly typed

// var b = new Set<String>();
// b.addAll(['dart', 'c#', 'j#', 'e#']);
Copy the code

Basic attributes

| | name that | | — – | — – | | isEmpty whether | null | | isNotEmpty | whether isn’t empty | | first | first | | last | last | | length number | |

Commonly used method

| | name that | | — – | — – | | addAll add | | | the contains a single | | queries | containsAll query | more | | difference different | | set | intersection computes Joint intersection | | | union | | | lookup | press object query to return objects | | remove | removing a single | | removeAll delete | more | | the clear empty | | | firstWhere | According to the condition of positive queries | | lastWhere | according to reverse the query conditions | | removeWhere | condition delete | | retainAll | keep only a few | | retainWhere | keep only a few | according to conditions

// b.addAll(['dart', 'c#', 'j#', 'e#']);
// print(b.contains('dart'));
// print(b.containsAll(['dart', 'swift']));
// print('b => $b');
// print(a.difference(b));
// print(a.intersection(b));
// print(b.lookup('dart'));
// print(b.union(a));
// b.remove('dart');
// b.removeAll(['dart','c#']);
// b.clear();
// print(b.firstWhere((it) => it == 'c#'));
// print(b.lastWhere((it) => it == 'c#'));
// b.removeWhere((it) => it == 'c#');
// b.retainAll(['e#']);
// b.retainWhere((it) => it == 'e#');
// b.retainWhere((it) {
// bool ret = it == 'e#';
// return ret;
// });
Copy the code

PDF document sorting:

Dart Basic Language Learning – Part 1. PDF

Blog Source: Blog of rainy Night