Are nested lists bad?

protected List<List> m_Leafs = new List<List>();

I’m working on a procedural house builder. To clarify, the size of the list changes depending on the building it’s generating. For example: a bungalow would use a single list, where a semi-detached house will have 2 as each part will be alike a building of it’s own.

Should I avoid nested lists, or perhaps are they looked down on?

Hi @Chikzter,

Every container has its own usage and own drawbacks. Lists of lists are not common, IMHO, but their usage really depend on precisely what you need.

You have to get in mind a few things (complexities and major features) about common containers for this. As an example, unsorted vectors (arrays, lists) are good for sequential reading and random access because data is contiguous in memory. But they aren’t for lookup, or frequent insertions & deletions. They also are very bad for insertions / deletions “in the middle” of the vector, since they require moving data.

For reference, you might look for “containers complexities [LANGUAGE]” in your favorite search engine. For instance you may get an eye on:

For C# : Collections and Data Structures | Microsoft Learn

For C++ : C++ STL Complexities

As a side note, handling building data may need much more than just “leaves”. Did you think about using a more complex backend, such as a small database? I personally used SQLite for local projects and found it useful.