find<K, V> method
查找满足条件的键值对。
参数:
返回值:
- 如果找到匹配的键值对,则返回该键值对,否则返回
null。
Implementation
MapEntry<K, V>? find<K, V>({Check<K>? key, Check<V>? value}) {
if (isNotEmpty(key) && isNotEmpty(value)) {
for (final entry in entries) {
if (key!(entry.key) && value!(entry.value)) {
return MapEntry(entry.key, entry.value);
}
}
}
if (isNotEmpty(key)) {
for (final entry in entries) {
if (key!(entry.key)) {
return MapEntry(entry.key, entry.value);
}
}
}
if (isNotEmpty(value)) {
for (final entry in entries) {
if (value!(entry.value)) {
return MapEntry(entry.key, entry.value);
}
}
}
return null;
}