import { Vector } from "https://deno.land/x/collections@v0.8.0/mod.ts";
A double-ended queue implemented with a growable ring buffer. Vector is faster than JavaScript's built in Array class for shifting and unshifting because it only requires reallocation when increasing the capacity.
Properties
Methods
Merges two or more iterables together. This does not change existing Iterables, it returns a new Vector.
Removes and returns the value at index from the vector. If the value is negative, it will be subtracted from the end. The values between the index and the end will be shifted to the left.
Returns an iterator for retrieving and removing values from the vector (from right-to-left).
Returns the value at the given index. If the value is negative, it will be subtracted from the end. The index 0 would return the first value in the vector. The index -1 would return the last value in the vector.
Creates and returns a new string concatenating all of the values in the Vector, separated by commas or a specified separator string.
Applies a function against an accumulator and each value of the vector (from left-to-right) to reduce it to a single value. If no initial value is supplied, the first value in the vector will be used and skipped. Calling reduce on an empty array without an initial value creates a TypeError.
Applies a function against an accumulator and each value of the vector (from right-to-left) to reduce it to a single value. If no initial value is supplied, the last value in the vector will be used and skipped. Calling reduce on an empty array without an initial value creates a TypeError.
Sets the value at the given index, then returns the value. If the value is negative, it will be subtracted from the end. The index 0 would set the first value in the vector. The index -1 would set the last value in the vector. If the absolute index value is greater than the length, the size will be increased to match before setting the value.
Returns a shallow copy of a portion of the vector into a new vector.
The start and end represent the index of values in the vector.
The end is exclusive meaning it will not be included.
If the index value is negative,
it will be subtracted from the end of the vector.
For example, vector.slice(-2)
would return a new vector
containing the last 2 values.
Converts the vector to an array.
It's recommended to use this instead of Array.from
because
this method is significantly faster.
Returns an iterator for retrieving values from the vector (from right-to-left).
Returns an iterator for retrieving values from the vector (from left-to-right).