VECTOR

template <typename T> pure Vector<T> vector();
template <typename T> pure Vector<T> vector(const T *a, size_t len);
pure Vector<char32_t> vector(String str);
template <typename T> pure Vector<T> vector(List<T> xs);
template <typename T> pure bool empty(Vector<T> v);
template <typename T> pure size_t size(Vector<T> v);
template <typename T> pure Vector<T> push_back(Vector<T> v0, T elem);
template <typename T> pure Vector<T> pop_back(Vector<T> v0);
template <typename T> pure Vector<T> push_front(Vector<T> v0, T elem);
template <typename T> pure Vector<T> pop_front(Vector<T> v0);
template <typename T> pure Vector<T> append(Vector<T> v0, Vector<T> v1);
template <typename T> pure const T &back(Vector<T> v);
template <typename T> pure const T &front(Vector<T> v);
template <typename T> pure const T &at(Vector<T> v, size_t idx);
template <typename T> pure Result<Vector<T>, Vector<T>> split(Vector<T> v, size_t idx);
template <typename T> pure Vector<T> left(Vector<T> v, size_t idx);
template <typename T> pure Vector<T> right(Vector<T> v, size_t idx);
template <typename T> pure Vector<T> between(Vector<T> v, size_t idx, size_t count);
template <typename T> pure Vector<T> insert(Vector<T> v, size_t idx, Vector<T> u);
template <typename T> pure Vector<T> erase(Vector<T> v, size_t idx, size_t count = 1);
template <typename T, typename A, typename F> pure A foldl(Vector<T> v, const A &arg, F func);
template <typename T, typename A, typename F> pure A foldr(Vector<T> v, const A &arg, F func);
template <typename U, typename T, typename F> pure Vector<U> map(Vector<T> v, F func);
template <typename T, typename F> pure Vector<T> filter(Vector<T> v, F func);
template <typename T> pure String show(Vector<T> v);
template <typename T> pure int compare(Vector<T> v, Vector<T> u);
template <typename T> pure bool verify(Vector<T> v);
template <typename T> VectorItr<T> begin(Vector<T> v);
template <typename T> VectorItr<T> end(Vector<T> v);
template <typename T> VectorItr<T> &operator ++(VectorItr<T> &i);
template <typename T> VectorItr<T> &operator --(VectorItr<T> &i);
template <typename T> VectorItr<T> &operator +(VectorItr<T> &i, ssize_t offset);
template <typename T> VectorItr<T> &operator -(VectorItr<T> &i, ssize_t offset);
template <typename T> VectorItr<T> &operator +=(VectorItr<T> &i, ssize_t offset);
template <typename T> VectorItr<T> &operator -=(VectorItr<T> &i, ssize_t offset);
template <typename T> pure T operator *(VectorItr<T> &i);
template <typename T> pure bool operator ==(const VectorItr<T> &i, const VectorItr<T> &j);
template <typename T> pure bool operator !=(const VectorItr<T> &i, const VectorItr<T> &j);

template <typename T>
pure Vector<T> vector()

Construct the empty vector. O(1).


template <typename T>
pure Vector<T> vector(const T *a, size_t len)

Construct a vector from a C-array. O(n).


pure Vector<char32_t> vector(String str)

Construct a vector from a string. O(n).


template <typename T>
pure Vector<T> vector(List<T> xs)

Construct a vector from a list. O(n).


template <typename T>
pure bool empty(Vector<T> v)

Test if a vector is empty. O(1).


template <typename T>
pure size_t size(Vector<T> v)

Vector size (a.k.a. vector length). O(1).


template <typename T>
pure Vector<T> push_back(Vector<T> v0, T elem)

Push an element to the back of a vector. O(1).


template <typename T>
pure Vector<T> pop_back(Vector<T> v0)

Pop the last element from a vector. O(1).


template <typename T>
pure Vector<T> push_front(Vector<T> v0, T elem)

Push an element to the front of a vector. O(1).


template <typename T>
pure Vector<T> pop_front(Vector<T> v0)

Pop the first element from a vector. O(1).


template <typename T>
pure Vector<T> append(Vector<T> v0, Vector<T> v1)

Append vectors. O(min(log(n), log(m))).


template <typename T>
pure const T &back(Vector<T> v)

Get the last element of a vector. O(1).


template <typename T>
pure const T &front(Vector<T> v)

Get the first element of a vector. O(1).


template <typename T>
pure const T &at(Vector<T> v, size_t idx)

Get the element at `idx'. O(log(n)).


template <typename T>
pure Result<Vector<T>, Vector<T>> split(Vector<T> v, size_t idx)

Vector split. O(log(n)).


template <typename T>
pure Vector<T> left(Vector<T> v, size_t idx)

Vector split left. O(long(n)).


template <typename T>
pure Vector<T> right(Vector<T> v, size_t idx)

Vector split right. O(log(n)).


template <typename T>
pure Vector<T> between(Vector<T> v, size_t idx, size_t count)

Vector between. O(log(n)).


template <typename T>
pure Vector<T> insert(Vector<T> v, size_t idx, Vector<T> u)

Vector insert. O(log(n)).


template <typename T>
pure Vector<T> erase(Vector<T> v, size_t idx, size_t count = 1)

Vector erase. O(log(n)).


template <typename T, typename A, typename F>
pure A foldl(Vector<T> v, const A &arg, F func)

Vector fold left. ([](A a, size_t idx, T elem) -> A). O(n).


template <typename T, typename A, typename F>
pure A foldr(Vector<T> v, const A &arg, F func)

Vector fold right. ([](A a, size_t idx, T elem) -> A). O(n).


template <typename U, typename T, typename F>
pure Vector<U> map(Vector<T> v, F func)

Vector map. ([](size_t idx, T elem) -> U). O(n).


template <typename T, typename F>
pure Vector<T> filter(Vector<T> v, F func)

Vector filter. ([](size_t idx, T elem) -> bool). O(n).


template <typename T>
pure String show(Vector<T> v)

Vector show. O(n).


template <typename T>
pure int compare(Vector<T> v, Vector<T> u)

Vector compare. O(n).


template <typename T>
pure bool verify(Vector<T> v)

Vector verify. O(n).


template <typename T>
VectorItr<T> begin(Vector<T> v)

Construct an iterator pointing to the start of a vector. O(1).


template <typename T>
VectorItr<T> end(Vector<T> v)

Construct an iterator pointing to the end of a vector. O(1).


template <typename T>
VectorItr<T> &operator ++(VectorItr<T> &i)

Vector iterator increment. O(1).


template <typename T>
VectorItr<T> &operator --(VectorItr<T> &i)

Vector iterator decrement. O(1).


template <typename T>
VectorItr<T> &operator +(VectorItr<T> &i, ssize_t offset)

Vector iterator add offset. O(log(1)).


template <typename T>
VectorItr<T> &operator -(VectorItr<T> &i, ssize_t offset)

Vector iterator substract offset. O(log(1))


template <typename T>
VectorItr<T> &operator +=(VectorItr<T> &i, ssize_t offset)

Vector iterator add offset. O(log(1))


template <typename T>
VectorItr<T> &operator -=(VectorItr<T> &i, ssize_t offset)

Vector iterator subtract offset. O(log(1))


template <typename T>
pure T operator *(VectorItr<T> &i)

Vector iterator dereference. O(log(delta)), where delta is distance to last dereference.


template <typename T>
pure bool operator ==(const VectorItr<T> &i, const VectorItr<T> &j)

Vector iterator same offset. O(1).


template <typename T>
pure bool operator !=(const VectorItr<T> &i, const VectorItr<T> &j)

Vector iterator different offset. O(1).