dart:core
庫中identityHashCode
函數的用法介紹如下。
用法:
int identityHashCode(
Object? object
)
object
的身份哈希碼。
返回原始 Object.hashCode 將在此對象上返回的值,即使 hashCode
已被覆蓋。
此哈希碼與 identical 兼容,這意味著它可以保證隨著時間的推移保持穩定。
var identitySet = HashSet(equals: identical, hashCode: identityHashCode);
var dt1 = DateTime.now();
var dt2 = DateTime.fromMicrosecondsSinceEpoch(dt1.microsecondsSinceEpoch);
assert(dt1 == dt2);
identitySet.add(dt1);
print(identitySet.contains(dt1)); // true
print(identitySet.contains(dt2)); // false
相關用法
- Dart identical用法及代碼示例
- Dart int.fromEnvironment用法及代碼示例
- Dart int.toUnsigned用法及代碼示例
- Dart int.bitLength用法及代碼示例
- Dart int.operator_shift_left用法及代碼示例
- Dart int.parse用法及代碼示例
- Dart int.toRadixString用法及代碼示例
- Dart int.operator_bitwise_and用法及代碼示例
- Dart int.operator_bitwise_exclusive_or用法及代碼示例
- Dart int.tryParse用法及代碼示例
- Dart int.operator_triple_shift用法及代碼示例
- Dart int.operator_bitwise_or用法及代碼示例
- Dart int.gcd用法及代碼示例
- Dart int.operator_shift_right用法及代碼示例
- Dart int.toSigned用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart AttributeClassSet.intersection用法及代碼示例
- Dart num.sign用法及代碼示例
- Dart TransformList.last用法及代碼示例
- Dart FileList.first用法及代碼示例
- Dart CanvasRenderingContext2D.drawImageScaledFromSource用法及代碼示例
- Dart FileList.length用法及代碼示例
- Dart Iterable.takeWhile用法及代碼示例
- Dart LinkedHashMap用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 identityHashCode function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。