vuoriov4

0

votes
1

answer
51

views

How to find the index of an element in a sorted vector given a pointer to that element

I have a vector std::vector vec. I'm trying to sort the vector and then find the index of an element given a pointer to it sort(vec.begin(), vec.end(), ...); auto index = myPointer - &vec[0]; I noticed that the value of index doesn't change when the vector is sorted and therefore is incorrect. Is t...
vuoriov4
1

votes
1

answer
159

views

Fastest way to do min-max based on specific component of vectors in GLSL?

I need to call this kind of function many many times in my GLSL code. vec2 minx(vec2 a, vec2 b) { if (a.x < b.x) return a; else return b; } I'm concerned of the excessive branching. Is there a way to do this avoiding if-else constructs?
vuoriov4