8 SQArray(
SQSharedState *ss,SQInteger nsize){_values.resize(nsize); INIT_CHAIN();ADD_TO_CHAIN(&_ss(
this)->_gc_chain,
this);}
11 REMOVE_FROM_CHAIN(&_ss(
this)->_gc_chain,
this);
16 new (newarray)
SQArray(ss,nInitialSize);
19 #ifndef NO_GARBAGE_COLLECTOR 21 SQObjectType GetType() {
return OT_ARRAY;}
28 if(nidx>=0 && nidx<(SQInteger)_values.size()){
35 bool Set(
const SQInteger nidx,
const SQObjectPtr &val)
37 if(nidx>=0 && nidx<(SQInteger)_values.size()){
45 SQUnsignedInteger idx=TranslateIndex(refpos);
46 if(idx<_values.size()){
48 outkey=(SQInteger)idx;
57 SQArray *Clone(){
SQArray *anew=Create(_opt_ss(
this),0); anew->_values.copy(_values);
return anew; }
58 SQInteger Size()
const {
return _values.size();}
59 void Resize(SQInteger size)
64 void Resize(SQInteger size,
SQObjectPtr &
fill) { _values.resize(size,fill); ShrinkIfNeeded(); }
65 void Reserve(SQInteger size) { _values.reserve(size); }
66 void Append(
const SQObject &o){_values.push_back(o);}
69 void Pop(){_values.pop_back(); ShrinkIfNeeded(); }
70 bool Insert(SQInteger idx,
const SQObject &val){
71 if(idx < 0 || idx > (SQInteger)_values.size())
73 _values.insert(idx,val);
76 void ShrinkIfNeeded() {
77 if(_values.size() <= _values.capacity()>>2)
78 _values.shrinktofit();
80 bool Remove(SQInteger idx){
81 if(idx < 0 || idx >= (SQInteger)_values.size())
Definition: squirrel.h:153
Definition: sqobject.h:205
signed char * fill(signed char *first, signed char *last, Value val)
Definition: algorithm.h:168
Definition: sqobject.h:313