C++ Vector at/[] operator speed

后端 未结 9 1649
借酒劲吻你
借酒劲吻你 2021-01-02 16:19

In order to give functions the option to modify the vector I can\'t do

curr = myvec.at( i );
doThis( curr );
doThat( curr );
doStuffWith( curr );
         


        
9条回答
  •  旧巷少年郎
    2021-01-02 17:20

    Vectors are the most suited for access speed. Access to a random element in a vector is of complexity O(1) compared with O(n) for general linked-lists and O(log n) for link-trees.

    However this question is mis-placed as the answer to your other question has lead you astray by not explaining how to fix your original problem by using a reference.

提交回复
热议问题