c# Adding a Remove(int index) method to the .NET Queue class

前端 未结 12 1523
攒了一身酷
攒了一身酷 2021-01-07 17:14

I would like to use the generic queue class as described in the .NET framework (3.5) but I will need a Remove(int index) method to remove items from the queue. Can I achieve

12条回答
  •  清酒与你
    2021-01-07 17:45

    Note that with a list you can make the "removal" process more efficient if you don't actually remove the item but merely "mark" it as "removed". Yes, you have to add a bit of code to deal with how you've done it, but the payoff is the efficiency.

    Just as one example - Say you have a List. Then you can, for example, just set that particular item to null and be done with it.

提交回复
热议问题