stl列表-复杂性 [英] stl list - complexity

查看:64
本文介绍了stl列表-复杂性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

列表常量是否全部插入(在任意位置)?

Are all the inserts (anywhere) for the list constant?

那访问呢?

正面,背面-恒定时间?

Front, back - constant time?

并且在列表的中间-线性时间?

and in the middle of the list - linear time?

推荐答案

任意位置插入

Inserts anywhere in a std::list are constant time operations.

也就是说,在插入之前,需要使迭代器到达您要插入的位置,这是线性时间操作,除非您在谈论正面或背面.

That said, before you can insert, you need to get an iterator to the location you'd like to insert to, which is a linear time operation unless you're talking about the front or back.

这篇关于stl列表-复杂性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆