Vec
A zero cost extension type of List
, representing a contiguous growable array. Unlike List
which is growable or non-growable,
which may cause runtime exceptions. Vec
adds new useful methods to the regular List
type.
It is built on rust_core and is a nice compliment to its Arr
(array) type.
Usage
import 'package:vec/vec.dart';
void main() {
Vec<int> vec = Vec(); // or e.g. Vec([1, 2, 3, 4])
List<int> list = vec.list; // easily translate back and forth
Vec<int> vec = Vec(list);
vec.push(5);
vec.insert(2, 99);
int removed = vec.remove(1);
vec.resize(10, 0);
RIterator<T> iterator = vec.extractIf((element) => element % 2 == 0);
Vec<T> spliced = vec.splice(start, end, replaceWith);
Slice<T> slice = vec.asSlice();
}