dart:core
庫中Object.hashAll
方法的用法介紹如下。
用法:
@Since("2.14")
int hashAll(
Iterable<Object?> objects
)
@Since("2.14")
為一係列對象創建組合哈希碼。
通過以迭代順序將每個元素的 Object.hashCode 進行數字組合,即使它們是 null
,也會為 objects
中的元素計算哈希碼。
hashAll([o])
的結果不是 o.hashCode
。
例子:
class SomeObject {
final List<String> path;
SomeObject(this.path);
bool operator ==(Object other) {
if (other is SomeObject) {
if (path.length != other.path.length) return false;
for (int i = 0; i < path.length; i++) {
if (path[i] != other.path[i]) return false;
}
return true;
}
return false;
}
int get hashCode => Object.hashAll(path);
}
在單個程序執行期間,使用具有相同哈希碼的對象以相同順序再次調用該函數時,計算值將保持一致。
此函數生成的哈希值是not
,保證在同一程序的不同運行期間或在同一程序的不同隔離區中運行的代碼之間保持穩定。使用的確切算法可能在不同平台之間或平台庫的不同版本之間有所不同,並且可能取決於每次程序執行時發生變化的值。
相關用法
- Dart Object.hashAllUnordered用法及代碼示例
- Dart Object.hash用法及代碼示例
- Dart Object.noSuchMethod用法及代碼示例
- Dart ObjectStore.openCursor用法及代碼示例
- Dart ObjectMirror.delegate用法及代碼示例
- 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 RegExp.pattern用法及代碼示例
- Dart StreamTransformer構造函數用法及代碼示例
- Dart JsArray.removeAt用法及代碼示例
- Dart ListMixin.expand用法及代碼示例
- Dart UriData.parse用法及代碼示例
- Dart Point用法及代碼示例
- Dart Int32x4List.view用法及代碼示例
- Dart Uri.decodeFull用法及代碼示例
- Dart Future用法及代碼示例
- Dart File用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 hashAll method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。