list or container O(1)-ish insertion/deletion performance, with array semantics

Posted by Chris Kaminski on Stack Overflow See other posts from Stack Overflow or by Chris Kaminski
Published on 2010-06-18T16:39:39Z Indexed on 2010/06/18 16:43 UTC
Read the original article Hit count: 271

Filed under:
|
|
|
|

I'm looking for a collection that offers list semantics, but also allows array semantics. Say I have a list with the following items:

apple orange carrot pear 

then my container array would:

container[0] == apple 
container[1] == orangle 
container[2] == carrot 

Then say I delete the orange element:

container[0] == apple 
container[1] == carrot 

I don't particularly care if sort order is maintained, I'd just like the array values to function as accelerators to the list items, and I want to collapse gaps in the array without having to do an explicit resizing.

© Stack Overflow or respective owner

Related posts about java

Related posts about c++