toMap<K, V> static method
Map<K, V>
toMap<K, V>(
- IIterator<
IKeyValuePair< iterator, {K, V> > - IKeyValuePair<
K, V> creator()?, - int length = 1,
Implementation
static Map<K, V> toMap<K, V>(
IIterator<IKeyValuePair<K, V>> iterator, {
IKeyValuePair<K, V> Function(Pointer<COMObject>)? creator,
int length = 1,
}) {
final pKeyValuePairArray = calloc<COMObject>(length);
try {
iterator.getMany(length, pKeyValuePairArray);
final keyValuePairs = pKeyValuePairArray.toList<IKeyValuePair<K, V>>(
creator ?? IKeyValuePair.fromRawPointer,
length: length);
final map = Map.fromEntries(
keyValuePairs.map((kvp) => MapEntry(kvp.key, kvp.value)));
for (final kvp in keyValuePairs) {
kvp.release();
}
return Map.unmodifiable(map);
} finally {
iterator.release();
free(pKeyValuePairArray);
}
}