java中sortedset_Java中SortedSet

java中sortedset_Java中SortedSetSortedSet 是个接口 它里面的 只有 TreeSet 这一个实现可用 中的元素一定是有序的 声明的主要接口 PublicMethod gt comparator Returnstheco 返回与此有序集合关联的比较器 如果使用元素的自然顺

SortedSet是个接口,它里面的(只有TreeSet这一个实现可用)中的元素一定是有序的。

声明的主要接口

Public Methods

abstract

Comparator super E>

comparator()

Returns the comparator used to compare elements in this

SortedSet.

返回与此有序集合关联的比较器,如果使用元素的自然顺序,则返回 null。

abstract E

first()

Returns the first element in this

SortedSet.

返回此有序集合中当前第一个(最小的)元素。

abstract

SortedSet

headSet(E end)

Returns a

SortedSet of the specified portion of this

SortedSet which contains elements less than the end element.

用一个SortedSet, 返回此有序集合中小于end的所有元素。

abstract E

last()

Returns the last element in this

SortedSet.

返回此有序集合中最后一个(最大的)元素

abstract

SortedSet

subSet(E start, E end)

Returns a

SortedSet of the specified portion of this

SortedSet which contains elements greater or equal to the start element but less than the end element.

返回此有序集合的部分元素,元素范围从 fromElement(包括)到 toElement(

不包括)。

abstract

SortedSet

tailSet(E start)

Returns a

SortedSet of the specified portion of this

SortedSet which contains elements greater or equal to the start element.

返回此有序集合的部分元素,其元素

大于或等于 fromElement。

注意:

1

:SortedSet意思是“根据对象的比较顺序”,而不是“插入顺序”进行排序.

2

:关于SortedSet的更多信息请参阅下面的它唯一实现类TreeSet。

3:关于SortedSe截取子串的时候,to都不包含,from包含

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177739.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月26日 下午6:50
下一篇 2026年3月26日 下午6:50


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号