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 vto the array. | 
| bool append(const T *ptr, size_t len) | Appends a sequence of Tspecified with a pointerptrand lengthlento the array. | 
| bool appendAll(const AutoVectorRooter<T> &other) | Appends all elements of otherto the array. | 
| bool insert(T *p, const T &val) | Inserts an element valat the position specified byp. | 
| void infallibleAppend(const T &v) | Appends an element vto 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 asJS::MutableHandle<T>. | 
| JS::Handle<T> operator[](size_t i) const | Returns to the i-th element asJS::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 Rangeof 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::AutoObjectVectorAdded in SpiderMonkey 24 | AutoVectorRooter<JSObject *> | 
| JS::AutoFunctionVectorAdded in SpiderMonkey 31 | AutoVectorRooter<JSFunction *> | 
| JS::AutoScriptVector | AutoVectorRooter<JSScript *> | 
See Also
- MXR ID Search for JS::AutoVectorRooter
- MXR ID Search for JS::AutoValueVector
- MXR ID Search for JS::AutoIdVector
- MXR ID Search for JS::AutoObjectVector
- MXR ID Search for JS::AutoFunctionVector
- MXR ID Search for JS::AutoScriptVector
- JS::AutoValueArray<N>- fixed-size array of- JS::Value
- bug 677079
- bug 868580 - expose JS::AutoObjectVector
- bug 848592 - added JS::AutoFunctionVector
- bug 676281 - added JS::AutoScriptVector