When are contiguous C++ arrays really faster than Java/C# ArrayLists? -
so kinda stole question title this isocpp entry on here.
when contiguous collection/container faster non-contiguous one?
- what inserting?
- accessing elements - matter whether elements pod (e.g.
double
) or complex object (e.g.std::string
) - copying array (and it's contents, depending on language)?
there tradeoffs made when using (c++) data structures. while std::vector
fine, , thing memory layout true, think people need understand in scenarios it's not great.
note: have pretty clear idea myself, provided isn't closed i'd see others think before provide possible answer myself.
if watch complete video, there kind of benchmark in middle shows scenario, cost of cache misses contiguous-but-not-really array (array of pointers in c#/java) can enormous, compared real contiguous std::vector storing actual elements , not pointers (using standard c++ value semantic).
Comments
Post a Comment