Skip to main content
GameDev.net gamedev.net
🔒 Locked

Translating an array without buffer?

Started by Lode Jun 29, 2004 at 12:30 PM 1 replies 400+ views
Original Post
Lode
Lode
I have a 2D array, and I'd like to bring the corners to the center and the center to the corners (so it's like translating it). Is there an efficient way to do this, without using an extra buffer? I already tried things similar to the xor swapping algorithm with it but it doesn't work...
Alpha_ProgDes
Alpha_ProgDes
does the swap function count as a buffer?

also is the array an array of ints or chars?
if it isn't then you'll have problem using the xor method.
Beginner in Game Development?  Read here. And read here.  
thomas001
thomas001
No it isn't a problem. you can swap every POD typ using xor. (you theoretical also can swap user class types using xor,but not calling the copy ctor might break things). if you e.g. want to swap floats using xor do evil casting to an 32bit int type (you probably wrote xor swapping for integral types,don't you?). like
xor_swap((uint32_t*)&float1,(uint32_t*)&float2);

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.