4 ms·
Anytime you do something that is immutable with probable change somewhere inside that is not easy to handle with far mor complex datastructure. In particular li
by di4na 4y ago
Anytime you do something that is immutable with probable change somewhere inside that is not easy to handle with far mor complex datastructure. In particular linked list are great for heterogeneous cells type.
Vectors and arrays have the problem of needing contiguous memory. If an inner cell can have different size, or worse change it mid work, things get ugly really fast.
- MontyCarloHall 4y agoWhy not just implement this as an array of constant width pointers to the heterogeneous data types?
- LorenPechtel 4y agoWhich is what happens in most modern languages. The items in your list are objects--which internally are just pointers to the data. There's no performance penalty for having variable-sized objects in the list.
- di4na 4y agoyou just defined how memory work, you are welcome :)