Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

std/vector

Vector is a growable heap-backed sequence.

import "std/vector";

fun main() {
    let v = Vector<int64>::with_capacity(1);
    v.push(10);
    v.push(20);
    let x = v.pop();
}

Current behavior:

  • Tracks length and capacity
  • Grows by doubling capacity
  • Deletes elements on destructor