I'm looking for a collection that provides the list of terms, but also allows array words. Say I have a list with the following items:
apple orange carrot pear
Then my container array is:
Then I remove the orange element:
I want to break the gap in the array without changing a clear shape, if I use the container Remove [0], then the container falls, this The container [1] is mapped as a container [0], and the container [1] as the container [1], etc. I still need access to the list with array syntax, and there are zero values' t permission (in the case of my special use)
Edit:
Answers to some questions To give - I know that o (1) is impossible, but I do not want a container with array irrments near O (log n). The purpose of the defeat was to aim, I could just iterate the list.
I basically had some vocabulary on sort order, I'm not sure what I was thinking at the time (Friday beer o-clock is most likely). One of the cases used is the QT list which contains images - deleting an image from the list is not necessary to collapse the list, take the last item from the list and put it in place. In this case, however, I want to preserve list words.
Important differences that I see in the list and array: array - continuous-time access list - arbitrary entry
If even refilling invalidates the ethers, then even more worried Are not there.
You are an array list / vector (Java / C ++) and when you delete, the last element with the previously deleted element Swap to So if you have ABCDE, and you delete C, then you will end up with Abe D. Note that the reference to E will be seen instead of 4 (assuming 0 indexes) instead of 4, but you have said that sort order is not a problem.
I do not know whether it handles automatically (adapted to easily remove from the end), but if not, you can easily write your own array-wrapper class You can.
Comments
Post a Comment