Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat type of container should I use to store my ObjectID integer?
    primarykey
    data
    text
    <p>I feel like this is a very simple, almost stupid question. I simply have forgotten what I should know how to do.</p> <p>I have GameObjects, which are stored in a universal GameObjectManager. These GameObjects have an ObjectID, which is a simple int.</p> <p>I need to be able to insert or remove these GameObjects in a 2D tile based world, where each TILE holds a container of ObjectID's.</p> <p>This way, I can grab a specific tile (ex. Tile[10][10]) and then see what GameObjects are on Tile[10][10] by reading from the container. (ex. "Ah, so Character#4302 and Item#123 are on Tile[10][10]!")</p> <p>Right now, each "Tile" is a structure in a MAP array of Tiles.</p> <pre><code> struct MapTile { std::vector &lt;int&gt; GameObject_MapList ; //list of Objects on this map location TileTerrainType tileTerrainType; //GFX to display Grass, Sand, Water, Swamp, etc. }; MapTile mlMap[100][100]; //map array </code></pre> <p>However, I read that Vectors should not be used when arbitrarily adding/removing variables. It is not like I will be removing the first or last variable in the array. Instead, I will have to call a specific ObjectID and remove it from wherever it is in the array.</p> <p>For this reason, I was thinking of using a different container. Maybe I am just too tired, but I could use some advice on what container to use, and how to go about removing SPECIFIC variables in the container.</p> <p>For example, GameObject has an ObjectID of "422". Tile[2][8] holds a container that has the following integers in order: 420, 421, 422, 433, 486, 800.</p> <p>I have a function: RemoveGameObjectFromMap(int ObjectID); So I need it to remove 422, whenever I type (RemoveGameObjectFromMap(422);</p> <p>I used to use a MAP container, but that is unnecessary. Vector, according to cplusplus.com would be bad for this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload