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

MethodDescription
size_t length() constReturns the length of the array.
bool empty() constDetermines 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&lt;T&gt;.
JS::Handle<T> operator[](size_t i) constReturns to the i-th element as JS::Handle&lt;T&gt;.
const T *begin() constReturns a pointer to the first element.
T *begin()Returns a pointer to the first element.
const T *end() constReturns 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() constReturns the last element.

Description

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

There are derived classes for the main types:

ClassParent class
JS::AutoValueVectorAutoVectorRooter<Value>
JS::AutoIdVectorAutoVectorRooter<jsid>
JS::AutoObjectVector Added in SpiderMonkey 24AutoVectorRooter<JSObject *>
JS::AutoFunctionVector Added in SpiderMonkey 31AutoVectorRooter<JSFunction *>
JS::AutoScriptVectorAutoVectorRooter<JSScript *>

See Also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:85 次

字数:6414

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文