The old thread is still worth talking about performance.
Given an N element inside an array or dictionary, you should consider performance when trying to access elements or to add or remove objects.
Arrays
In access, a random element will cost you the same as access to the first or last, since the elements follow one after another, therefore they are accessed directly. They will cost you 1 cycle.
Inserting an item is expensive. If you add to the beginning, it will cost you 1 cycle. Inserting in the middle, the remainder needs to be shifted. It may cost you as much as the worst-case N-cycle (average N / 2 cycle). If you join the end and you have enough space in the array, it will cost you 1 cycle. Otherwise, the entire array will be copied, which will cost you N cycles. This is why it is important to assign enough space to the array at the start of the operation.
Removing from the very beginning or the end will cost you 1. An average shift operation is required. On average, this is N / 2.
Finding an item with a given property will cost you N / 2 cycles.
Therefore, be very careful with huge arrays.
Dictionaries
While the dictionaries are disordered, they can bring you some advantages here. Since keys are hashed and stored in a hash table, any operation will cost you 1 cycle. Only an exception can find an element with a given property. This may cost you N / 2 cycles in the worst case. With smart design, however, you can assign property values โโas dictionary keys, so a search will cost you 1 cycle only no matter how many elements are inside.
Teddy source share