Vectors vs linked lists

I'm currently using vectors to store the tiles for my levels. I was wondering if using vectors is too slow and that I should look into implementing a linked list. I've used linked lists multiple times in the 5 years of programming that I've taken throughout high school and college so implementing them wouldn't be too much of a pain, but I'd like to avoid it.

If you are planning to access all of the tiles in sequence, then yes, use a linked list. Otherwise, for random access a vector will be much more convenient and probably faster too. What language are you using?

First, bear in mind that these tiles will likely be loaded when each level is loaded -- or even when a game starts. This means that there will likely be no changes in the tile-storage data structure when in a level.

If all your tiles are some fixed size, then you can put all their data into a single vector. From that size, you can find the multiplier from tile index to index in the data vector.

But if they vary in size, then you may need another vector that contains, for each tile

Width
Height
Offset

or

Width
Height
Pointer to Individually-Allocated Data

There is also the problem of how the tiles are referred to from the rest of your code and data. Are they referred to by indiex? By collection number and index? By name?

Collection number can be taken care of by creating an array of tile vectors, but named tiles are more difficult. A simple way of handling named tiles is to search for a tile by scanning through the list and checking each tile name for a match.

However, that's needlessly slow; there are some alternatives. One is to set up a binary search by sorting the tiles by name. This can be done with a minimum of data shuffling by doing an index sort -- sorting only indices of the data objects. Another is to construct a hash table. One constructs an index from a name, and then uses that index to look up an entry in a hash table. This table will have been set up by scanning through the list of tiles, calculating hash indices from the tiles' names, and then placing the tile indices at the hash-table locations indicated by the hash indices. Sometimes, more than one name may share the same hash index. There are a number of ways to handle such "hash collisions":

If a tile index in the hash table turns out to be incorrect, then search through the tiles for a match and update the hash table with one's success.

Construct a linked list of same-hash-index tiles; one can do this by adding a "Next" field to the tile data, with the final entry having index -1 or something like that.