Difference between revisions of "Talk:C++"
From GnuCash
(std::vector is better than std::list for most use-cases in Gnucash) |
(No difference)
|
Revision as of 16:10, 18 November 2013
std::vector vs. std::list
Christian Stimming commented in-line that "std::vector isn't the correct analogy to GList, std::list is".
JRalls: That's true, but most of the time we use GList to get a run-time extensible collection that can be iterated. Std::vector meets both of those requirements with vastly better performance and code size compared to std::list. Lists are better only in the case where one needs to frequently insert items into the middle or to reorder the items, both rather expensive operations for std::vector. I haven't found many places in Gnucash where the former is required, and only the Transaction splits list fits the latter. Note as well that GLib lacks a vector-like class, so the only extensible-and-iterable container is GList.