indexOf(Object
o):
Returns the index in this list of the first
occurrence of the specified element, or -1
if
this list does not contain this element. More formally, returns the lowest index
i such that (o==null ? get(i)==null :
o.equals(get(i))), or -1 if there is no such index.
subList(int
fromIndex, int toIndex):
Returns a view of the portion of this list
between the specified fromIndex, inclusive, and toIndex,
exclusive
. (If fromIndex and toIndex are equal, the returned list is
empty.) The returned list is backed by this list, so non-structural changes in
the returned list are reflected in this list, and vice-versa. The returned list
supports all of the optional list operations supported by this list.
sort(List):
Sorts the specified list into ascending
order, according to the natural ordering of its elements. All elements in the
list must implement the Comparable interface. Furthermore, all elements in the
list must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException
for any elements e1 and e2 in the list).
This sort is guaranteed to be stable: equal
elements will not be reordered as a result of the sort.
The specified list must be modifiable, but
need not be resizable.
The sorting algorithm is a modified mergesort
(in which the merge is omitted if the
highest element in the low sublist is less than the lowest element in the high
sublist). This algorithm offers guaranteed n log(n) performance. This
implementation dumps the specified list into an array, sorts the array, and
iterates over the list resetting each element from the corresponding position
in the array. This avoids the n2log(n) performance that would result from
attempting to sort a linked list in place.
shuffle(java.util.List,
java.util.Random):
Randomly
permute the specified list using the specified source of randomness. All
permutations occur with equal likelihood assuming that the source of randomness
is fair.
This
implementation traverses the list backwards, from the last element up to the
second, repeatedly swapping a randomly selected element into the "current
position". Elements are randomly selected from the portion of the list
that runs from the first element to the current position, inclusive.
This method
runs in linear time. If the specified list does not implement the RandomAccess
interface and is large, this implementation dumps the specified list into an
array before shuffling it, and dumps the shuffled array back into the list.
This avoids the quadratic behavior that would result from shuffling a
"sequential access" list in place.
retainAll()
Retains only the elements in this list that
are contained in the specified collection (optional operation). In other words,
removes from this list all the elements that are not contained in the specified
collection.
分享到:
相关推荐
MFC控件:listctrl使用方法总结
在日常的业务开发中,可能会遇到需要将 List 集合...本文通过多种方法详细解决的去重处理,可以是排序的,可以是不需要新建集合的,实现最简洁,且去重之后的顺序能和原集合保持一致的实现方法;小伙伴们一起来看看吧!
详细总结Scala语言的List类封装的相关方法,具有详细的方法名及解析
C++中list的使用方法及常用list操作总结 一、List定义: List是stl实现的双向链表,与向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比较慢。使用时需要添加头文件 #include <list> 二、List定义和...
找了一些关于checkboxList控件的常用用法 添加项,选择项,删除项的等17种常用的方法。 希望对大家有用
主要介绍了java list常用方法总结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
计算机后端-Java-Java核心基础-第24章 集合01 18. List遍历及方法总结.avi
里面包含C# list 里面各种linq 方法使用
。。。
。。。
详细总结了wxpython中Listctrl方法使用。
首先定义一个compare函数: def compare(sf1, sf2): if (sf1.value > sf2.value): return -1; elif (sf1.value == sf2.value): return 0;...总结 以上所述是小编给大家介绍的Python对List中的元素排
主要介绍了Python list操作用法,以实例形式较为详细的总结分析了Python中list的各种常见函数的功能与使用方法,需要的朋友可以参考下
下面小编就为大家带来一篇java中循环删除list中元素的方法总结。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
在本篇文章中小编给大家分享了关于HashMap和List遍历方法及如何遍历删除元素知识点总结,需要的朋友们参考下。
本人用半天的时间总结了一下set、map、list以及collection的区别,其中也包括增强for循环的经典实用。
主要介绍了Python对列表list中的值进行去重的方法总结,文中给出的方法都能保持去重后的顺序不发生改变,需要的朋友可以参考下
Iterator to list的三种方法 简介 集合的变量少不了使用Iterator,从集合Iterator非常简单,直接调用Iterator方法就可以了。 那么如何从Iterator反过来生成List呢?今天教大家三个方法。 使用while 最简单最基本的...
下面小编就为大家带来一篇Java中四种遍历List的方法总结(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧