Collections类中常用算法之Rotate

Collections类中常用算法之Rotate

Collections类简介

Collections类是java集合框架的一个类,其主要是一些通用的作用于Collection的 算法,如排序,求极值,混淆(shuffle)等。
引用Java官方文档的介绍

The polymorphic algorithms described here are pieces of reusable functionality provided by the Java platform. All of them come from the Collections class, and all take the form of static methods whose first argument is the collection on which the operation is to be performed. The great majority of the algorithms provided by the Java platform operate on List instances, but a few of them operate on arbitrary Collection instances.

Collections类的方法都是静态方法,每一种方法都对应一种集合算法的实现,且每一种实现都有两种,一种是适用于实现了RandomAccess接口的集合类(例如ArrayList),另一种是适用于序列存储的,例如(LinkedList)。

Collections类包含的算法实现大致如下:

  • 排序
    排序采用归并排序,所以排序算法是稳定的,时间复杂度是确定的。
  • 混淆
  • 常规的集合数据操作(适用于List
    包括reversefillcopyswapaddAll
  • 搜索(适用于List
    binarySearch
  • 极值
    求集合的最大元素、最小元素

Collections中的大多数算法都只是适用于List,接下来讨论的Rotate方法就是只适用于List的。
使用

  • 4
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值