Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Vectors: Sorting and removing specific items

$
0
0
I'm looking at a new approach for rendering stuff where basically I have this std::vector of renderables. At some point renderables are added to the vector and when it comes time to draw they're sorted and drawn. But I have a few fuzzy parts: 1. I know there is std::sort function where you can give a compare function, but its signature wants a bool. So what happens if the 2 objects I'm comparing are considered equal? I know in other languages they return 1 for greater then, 0 for equal, and -1 for less then 2. What's best/quickest way to remove a specific item from my std::vector<Renderables*>? Would it be better to have a map since I want to remove specific items? How would this effect sorting and traversing the map if this is the case?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>