Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法创建一个std::vector类似列表,但它只包含1 个值,没有键。
std::vector
我基本上想做的是存储一大堆实体。如果我可以按键删除对象也很好。(例如map::remove(Entity*);)
map::remove(Entity*);
是的。它被称为std::set。它是一组特定类型的值。
std::set
例如:
std::set<int>
int
std::set<Entity>
Entity
std::set<Entity *>
我想你的意思是std::map,不是std::vector吗?
std::map
在这种情况下,您可以使用std::setorstd::unordered_set
std::unordered_set