Skip to content

为LinkedList提供反向遍历的方法 #6

Description

@hjkl950217

默认LinkedList返回的迭代器是正向的,反向没有。如果调用System.Linq.Enumerable.Reverse,根据官方设计会先正向遍历一次然后反向迭代,不是特别好。

可以利用双向链表的结构优势扩展一个反向遍历的方法,可选:

  1. 模仿官方源代码的方式扩展一个方法,返回反向迭代器。
  2. 直接扩展一个方法,能输出反向的数组。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions