JS::AutoVectorRooter

This article covers features introduced in SpiderMonkey 17

Base class that roots an internal variable-size array of type T.

Syntax

JS::AutoVectorRooter(JSContext* cx);

Methods

Method Description
size_t length() const Returns the length of the array.
bool empty() const Determines if the array is empty (length is zero).
bool append(const T &v) Appends an element v to the array.
bool append(const T *ptr, size_t len) Appends a sequence of T specified with a pointer ptr and length len to the array.
bool appendAll(const AutoVectorRooter<T> &other) Appends all elements of other to the array.
bool insert(T *p, const T &val) Inserts an element val at the position specified by p.
void infallibleAppend(const T &v) Appends an element v to the array. For use when space has already been reserved.
void popBack() Pops an element from the array.
T popCopy() Pops an element from the array and returns it.
bool growBy(size_t inc) Grows the array by inc.
bool resize(size_t newLength) Resizes the array to newLength.
void clear() Clears all elements.
bool reserve(size_t newLength) Reserves the array with newLength.
JS::MutableHandle<T> operator[](size_t i) Returns to the i-th element as JS::MutableHandle<T>.
JS::Handle<T> operator[](size_t i) const Returns to the i-th element as JS::Handle<T>.
const T *begin() const Returns a pointer to the first element.
T *begin() Returns a pointer to the first element.
const T *end() const Returns a pointer to the element next to the last element.
T *end() Returns a pointer to the element next to the last element.
Range all() Returns the Range of the array.
const T &back() const Returns the last element.

Description

JS::AutoVectorRooter<T> holds a variable-size rooted array of type T.

There are derived classes for the main types:

Class Parent class
JS::AutoValueVector AutoVectorRooter<Value>
JS::AutoIdVector AutoVectorRooter<jsid>
JS::AutoObjectVector Added in SpiderMonkey 24 AutoVectorRooter<JSObject *>
JS::AutoFunctionVector Added in SpiderMonkey 31 AutoVectorRooter<JSFunction *>
JS::AutoScriptVector AutoVectorRooter<JSScript *>

See Also

Document Tags and Contributors

 Contributors to this page: chaser92, kscarfone, arai
 Last updated by: chaser92,