PersistentMap<K, V> class

PersistentMap used a DBM database to provide an implementation of the dart Map interface which transparently saves the Map to disk

Implemented types

Constructors

PersistentMap(DBM _dbm, Uint8List _keySerializer(K), K _keyDeserializer(Uint8List), Uint8List _valueSerializer(V), V _valueDeserializer(Uint8List), {bool valueComparator(V, V)?})
Create a new PersistentMap, with the underlying dbm database, key and value serialization functions, and an optional value comparator.

Properties

entries Iterable<MapEntry<K, V>>
The map entries of this Map.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether there is no key/value pair in the map.
no setteroverride
isNotEmpty bool
Whether there is at least one key/value pair in the map.
no setteroverride
keys Iterable<K>
The keys of this Map.
no setteroverride
length int
The number of key/value pairs in the map.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
values Iterable<V>
The values of this Map.
no setteroverride

Methods

addAll(Map<K, V> other) → void
Adds all key/value pairs of other to this map.
override
addEntries(Iterable<MapEntry<K, V>> newEntries) → void
Adds all key/value pairs of newEntries to this map.
override
cast<RK, RV>() Map<RK, RV>
This method is not implemented by this map implementation and will result in an exception being thrown.
override
clear() → void
Removes all entries from the map.
override
close() → void
Close this database
containsKey(dynamic key) bool
Whether this map contains the given key.
override
containsValue(dynamic value) bool
Checks to see if the map contains a value. The result of this is dictated by the comparator function passed when creating the PersistentMap and uses it to check every entry value until a match is found. The function should therefore be capable of deep comparisons for structured types. Given that this function will check every value until a match is found it can potentially have significant performance impact.
override
forEach(void action(K key, V value)) → void
Applies action to each key/value pair of the map.
override
map<K2, V2>(MapEntry<K2, V2> convert(K key, V value)) Map<K2, V2>
Map from a PersistentMap to a memory-resident map created by applying a mapping function to each key-value pair.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
putIfAbsent(K key, V ifAbsent()) → V
Look up the value of key, or add a new entry if it isn't there.
override
remove(Object? key) → V?
Removes key and its associated value, if present, from the map.
override
removeWhere(bool test(K key, V value)) → void
Removes all entries of this map that satisfy the given test.
override
toString() String
A string representation of this object.
inherited
update(K key, V ifPresent(V value), {V ifAbsent()?}) → V
Updates the value for the provided key.
override
updateAll(V update(K key, V value)) → void
Updates all values.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited
operator [](Object? key) → V?
The value for the given key, or null if key is not in the map.
override
operator []=(K key, V value) → void
Associates the key with the given value.
override

Static Methods

make<K1, V1>(File file, Uint8List keySerializer(K1), K1 keyDeserializer(Uint8List), Uint8List valueSerializer(V1), V1 valueDeserializer(Uint8List), {bool create = false, bool comparator(V1, V1)?}) PersistentMap<K1, V1>
Create a PersistentMap with K1 for keys and V1 for values, with file being the database file, and create specifying whether to create a new file if it doesn't exist. If file already exists, the file will not be overwritten, but rather opened. The serializers for the keys and values must be provided when calling this function. If file contains and incompatible database, behavior is unspecified.
withMapValue(File file, {bool create = false, bool comparator(Map<String, dynamic>, Map<String, dynamic>)?}) PersistentMap<String, Map<String, dynamic>>
Create a PersistentMap with strings for keys and maps for values, with file being the database file, and create specifying whether to create a new file if it doesn't exist. If file already exists, the file will not be overwritten, but rather opened. If file contains and incompatible database, behavior is unspecified. Note that the value must be convertible using the json functions in dart:convert
withStringValue(File file, {bool create = false}) PersistentMap<String, String>
Create a PersistentMap with strings for keys and values, with file being the database file, and create specifying whether to create a new file if it doesn't exist. If file already exists, the file will not be overwritten, but rather opened. If file contains and incompatible database, behavior is unspecified.