✅ which is better ?

So I have class Room and I’m trying to do some optomization I created a List of room and then created a function that makes a loop in the list and return the room if it matches the id. Now thinking about it i can also make a Dictionary<int, room> and access room with the id which one is better ?
2 Replies
Pobiega
Pobiega11mo ago
Dictionary access is faster than looping over a list. The difference is minimal for small numbers of items, but as your collection grows the list loop access time will grow several orders of magnitude faster than dictionary
𝔄ℑ𝔇𝔈𝔑
𝔄ℑ𝔇𝔈𝔑OP11mo ago
Ty
Want results from more Discord servers?
Add your server