ChaiScript
Public Member Functions | List of all members
ChaiScript_Language::Vector Class Reference

A vector of Objects. More...

#include <chaiscript_prelude_docs.hpp>

Public Member Functions

Object operator[] (int t_index)
 returns the Object at the given index. Throws an exception if the index does not exist
 
const Object operator[] (int t_index) const
 returns a const Object at the given index. Throws an exception if the index does not exist.
 
Object back ()
 returns the last item in the Vector
 
void clear ()
 Clears the Vector of all items.
 
bool empty ()
 Returns true if the Vector is contains 0 items.
 
void erase_at (int t_index)
 Erases the element at the given index.
 
Object front ()
 Returns the first item in the Vector.
 
void insert_ref_at (int, Object)
 Inserts a new item in the Vector at the given index. More...
 
void insert_at (int, Object)
 Inserts a new item in the Vector at the given index. More...
 
void pop_back ()
 Removes the last item from the Vector.
 
void push_back_ref (Object)
 Adds an item to the end of the Vector. More...
 
void push_back (Object)
 Adds an item to the end of the Vector. More...
 
Range range ()
 Returns a Range object for the entire vector.
 
Const_Range range () const
 Returns a Const_Range object for the entire vector.
 
int size () const
 Returns the number of elements in the Vector.
 

Detailed Description

A vector of Objects.

ChaiScript includes a shortcut for creating a Vector of Objects

Example:

eval> var v = [1,2,3,4]
[1, 2, 3, 4]
eval> v[0];
1
eval> v.size();
4

Implemented with std::vector<chaiscript::Boxed_Value>

See also
chaiscript::bootstrap::standard_library::vector_type

Member Function Documentation

◆ insert_at()

void ChaiScript_Language::Vector::insert_at ( int  ,
Object   
)

Inserts a new item in the Vector at the given index.

The item is cloned on insert

See also
insert_ref

◆ insert_ref_at()

void ChaiScript_Language::Vector::insert_ref_at ( int  ,
Object   
)

Inserts a new item in the Vector at the given index.

The item is not cloned on insert

See also
insert_ref

◆ push_back()

void ChaiScript_Language::Vector::push_back ( Object  )

Adds an item to the end of the Vector.

The item is cloned.

See also
push_back_ref

◆ push_back_ref()

void ChaiScript_Language::Vector::push_back_ref ( Object  )

Adds an item to the end of the Vector.

The item is not cloned.

See also
push_back

The documentation for this class was generated from the following file: