【问题标题】:Why does the LinkedList mutable iterator not have a `remove_next` method?为什么 LinkedList 可变迭代器没有 `remove_next` 方法?
【发布时间】:2015-04-14 10:52:34
【问题描述】:

我想要 O(1) 删除 LinkedList::IterMut.Vec 中的节点或其他不能。

【问题讨论】:

  • 粗略一看,很多方法可以被认为是“缺失”的;最可能的原因是还没有人实现它们……如果这不是您所要求的,那么您能否具体说明您的问题?
  • @MatthieuM。是的,“还没有人实现它们”或“由于某种原因,没有人实现它们”
  • LinkedList 上没有 O(1) 删除。如果您在迭代器中使用它,则迭代到该点需要花费您。更多Vec#swap_remove,O(1) 删除而不保留​​排序。

标签: rust


【解决方案1】:

没有remove_next 方法的最可能原因是,Rust 团队正在评估游标作为替代方法:

#[inline]
#[unstable(feature = "collections",
           reason = "this is probably better handled by a cursor type -- we'll see")]

[Source]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-03
    • 2015-01-27
    • 2012-11-24
    • 2015-01-22
    • 2020-08-15
    • 1970-01-01
    • 2018-08-13
    • 1970-01-01
    相关资源
    最近更新 更多