Jump to content

[SOLVED] Vector insert()


photo

Recommended Posts

problem

 

We need to add data to UNIGINE vector array at a specific index position to keep reqired ordering. Supprisingly we realized that there is no insert( int index ) operation ( like opposit remove( int index ) ) available, only append() for adding new data to the end of the array.

 

Though it would be possible to resort array after each insert operation this would be VERY inefficient for large arrays

 

 

proposal

 

Addition of efficient vector::insert( int index, int value ) operation

Link to comment

BTW it might also be worse thinking about an additional allocate( int numElements ) operation for pre-allocation of larger memory chunks. This could avoid/significantly reduce re-occuring memory allocations on element inserts (comparable to ObjectBillboards::allocateBillboards() ) when upper size limit of vector is already known ahead of time (as in our case)

Link to comment

Two-argument version of append() function performs insert(index,value) operation.

 

Ok, didn't know that. Documentation of vector append seems to be misleading as it states that data will be appended to end. Two-argument version description only focusses on map key/value append, not on vector. Maybe this should be clarified a litte bit.

 

 

vector.allocate() will be available in the next SDK.

 

great

Link to comment
  • 3 weeks later...
×
×
  • Create New...