public void RemoveQuad(IQuad quad)
{
int iI = quad.Index_Indices;
int iV = quad.Index_Vertices;
this.vertices_Dictionary[this.effect_Type].RemoveRange(quad.Index_Vertices, GameConstants.QUAD_NUMBER_OF_VERTICES);
this.indices_Dictionary[this.effect_Type].RemoveRange(quad.Index_Indices, GameConstants.QUAD_NUMBER_OF_INDICES);
// Because a Quad has been removed
foreach (IQuad quad_Stored in quad_List)
{
if (quad_Stored.Index_Vertices > iV)
{
quad_Stored.Index_Vertices -= GameConstants.QUAD_NUMBER_OF_VERTICES;
quad_Stored.Index_Indices = (quad_Stored.Index_Vertices / GameConstants.QUAD_NUMBER_OF_VERTICES) * 6;
}
}
...
[C#] I'm looking for a more efficient way of removing items from a list
Hi guys,
Currently I have a list of stored Quads that must have their Index_ properties changed when an Quad is removed from 2 other Dictionaries (Vertex & Index).
The problem is while this method works, it is far from efficient as it has to iterate through the same list containing all Quads each time a Quad is removed:
As you can see when removing the current Quad (based on the current Quad's Index_Vertices & Index_Indices properties) from the two Dictionaries the remaining Quads must have their Index_ properties updated so they point to the right place in the Dictionaries.
The problem is that the foreach iteration is being called every time a Quad is removed, this is far from ideal.
How could I go about only having to reorganize all the Quad.Index_Vertices/Indices once after all Quads have been removed. I can't figure out a good way since the Quads would not be deleted in any particular order.
Thank you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement