vec 0.2.1 copy "vec: ^0.2.1" to clipboard
vec: ^0.2.1 copied to clipboard

discontinuedreplaced by: rust_core

A zero cost growable vector type

Vec #

Pub Version Dart Package Docs License: MIT Build Status

A zero cost extension type of List, representing a contiguous growable array. Unlike List which is growable or non-growable. Vec 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);

  vec.forEach((element) {
    print(element);
  });

  // Use custom iterator to extract elements based on a condition
  var iterator = vec.extractIf((element) => element % 2 == 0);
  iterator.forEach((element) {
    print('Extracted: $element');
  });

  Vec<T> spliced = vec.splice(start, end, replaceWith);

  Slice<T> slice = vec.asSlice();
}
1
likes
0
pub points
0%
popularity

Publisher

verified publishervoyver.com

A zero cost growable vector type

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

rust_core

More

Packages that depend on vec