Skip to content

Commit

Permalink
ListMap.insert method.
Browse files Browse the repository at this point in the history
  • Loading branch information
marcglasberg committed Jun 5, 2024
1 parent 02bf90b commit de84b76
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/src/list_map/list_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ class ListMap<K, V> implements Map<K, V> {
throw UnsupportedError("This is not yet supported, but will be in the future.");
}

/// Inserts [key]/[value] at position [index].
///
/// If the [key] already exists, the previous one will first be removed.
///
/// Then, it will shift all objects at or after the index towards the end of the list,
/// and add it at the given position.
///
/// This only works if the `ListMap` is growable.
/// The [index] value must be non-negative and no greater than [length].
///
void insert(int index, K key, V value) {
// TODO: Implement
throw UnsupportedError("This is not yet supported, but will be in the future.");
}

@override
void addEntries(Iterable<MapEntry<K, V>> newEntries) {
// TODO: Implement
Expand Down
6 changes: 6 additions & 0 deletions lib/src/list_map/list_map_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,10 @@ class ListMapView<K, V> implements ListMap<K, V> {
// TODO: Implement
throw UnsupportedError("This is not yet supported, but will be in the future.");
}

@override
void insert(int index, K key, V value) {
// TODO: Implement
throw UnsupportedError("This is not yet supported, but will be in the future.");
}
}

0 comments on commit de84b76

Please sign in to comment.