Jump to content

swap function


photo

Recommended Posts

Hello,

 

Unigine Docs: Unigine Script lists a function called:

 

void swap(variable v0, variable v1)

 


int a [4] = (2, 3, 4, 5);
//swap(a[0], a[1]);  // Interpreter::parse(): unknown token "swap"
int b = 4;
int c = 5;
swap(b,c); // Interpreter::parse(): unknown token "swap"
for(int i= 0; i < a.size(); i++){
   log.message(string(a[i]));
}


 

1) Why is this token not known?

 

2) Is it okay if I swap elements of an array? Is it okay if the elements of the array are objects, as opposed to primitives?

 

Foo foos [2];
foos[0] = new Foo(1);
foos[1] = new Foo(2);
swap(foos[0], foos[1]); // is this legal? Will it switch the Foos around in the vector?

Link to comment
×
×
  • Create New...