forward-list

std::forward_list and std::forward_list::push_back

徘徊边缘 提交于 2019-11-27 08:04:51
I'd like to use std::forward_list Because: Forward list is a container which supports fast insertion and removal of elements from anywhere from the container But there's no *std::forward_list::push_back* implementation. Is there a high-performance way to add support for the one or no reason to do it? kennytm std::forward_list supports fast insertion and removal, but not traversal to the end . To implement .push_back , you'll first need to get to the end of the list, which is O(N) and not fast at all, which is probably why it's not implemented. You could find the iterator to the last element by

std::forward_list and std::forward_list::push_back

╄→尐↘猪︶ㄣ 提交于 2019-11-26 14:02:59
问题 I'd like to use std::forward_list Because: Forward list is a container which supports fast insertion and removal of elements from anywhere from the container But there's no *std::forward_list::push_back* implementation. Is there a high-performance way to add support for the one or no reason to do it? 回答1: std::forward_list supports fast insertion and removal, but not traversal to the end . To implement .push_back , you'll first need to get to the end of the list, which is O(N) and not fast at