dart:collection
庫中SplayTreeSet.add
方法的用法介紹如下。
用法:
bool add(
E element
)
override
將value
添加到集合中。
如果集合中還沒有value
(或相等的值),則返回true
。否則返回 false
並且集合不會改變。
例子:
final dateTimes = <DateTime>{};
final time1 = DateTime.fromMillisecondsSinceEpoch(0);
final time2 = DateTime.fromMillisecondsSinceEpoch(0);
// time1 and time2 are equal, but not identical.
assert(time1 == time2);
assert(!identical(time1, time2));
final time1Added = dateTimes.add(time1);
print(time1Added); // true
// A value equal to time2 exists already in the set, and the call to
// add doesn't change the set.
final time2Added = dateTimes.add(time2);
print(time2Added); // false
print(dateTimes); // {1970-01-01 02:00:00.000}
assert(dateTimes.length == 1);
assert(identical(time1, dateTimes.first));
print(dateTimes.length);
相關用法
- Dart SplayTreeSet.addAll用法及代碼示例
- Dart SplayTreeSet.lookup用法及代碼示例
- Dart SplayTreeSet.isEmpty用法及代碼示例
- Dart SplayTreeSet.remove用法及代碼示例
- Dart SplayTreeSet.isNotEmpty用法及代碼示例
- Dart SplayTreeSet.retainAll用法及代碼示例
- Dart SplayTreeSet.toSet用法及代碼示例
- Dart SplayTreeSet.clear用法及代碼示例
- Dart SplayTreeSet.removeAll用法及代碼示例
- Dart SplayTreeSet.of用法及代碼示例
- Dart SplayTreeSet.from用法及代碼示例
- Dart SplayTreeSet.contains用法及代碼示例
- Dart SplayTreeSet.intersection用法及代碼示例
- Dart SplayTreeSet.difference用法及代碼示例
- Dart SplayTreeSet.union用法及代碼示例
- Dart SplayTreeSet用法及代碼示例
- Dart SplayTreeMap.from用法及代碼示例
- Dart SplayTreeMap.containsValue用法及代碼示例
- Dart SplayTreeMap.addAll用法及代碼示例
- Dart SplayTreeMap.fromIterables用法及代碼示例
- Dart SplayTreeMap.fromIterable用法及代碼示例
- Dart SplayTreeMap.clear用法及代碼示例
- Dart SplayTreeMap.forEach用法及代碼示例
- Dart SplayTreeMap.putIfAbsent用法及代碼示例
- Dart SplayTreeMap用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 add method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。