SortedSet接口源码解析

SortedSet接口为TreeSet做准备

可以实现排序集合

源码


package java.util;

public interface SortedSet<E> extends Set<E> {
    /**
     * 比较器
     */
    Comparator<? super E> comparator();

    /**
     * 获取子集
     * @throws ClassCastException if <tt>fromElement</tt> and
     *         <tt>toElement</tt> cannot be compared to one another using this
     *         set‘s comparator (or, if the set has no comparator, using
     *         natural ordering).  Implementations may, but are not required
     *         to, throw this exception if <tt>fromElement</tt> or
     *         <tt>toElement</tt> cannot be compared to elements currently in
     *         the set.
     * @throws NullPointerException if <tt>fromElement</tt> or
     *         <tt>toElement</tt> is null and this set does not permit null
     *         elements
     * @throws IllegalArgumentException if <tt>fromElement</tt> is
     *         greater than <tt>toElement</tt>; or if this set itself
     *         has a restricted range, and <tt>fromElement</tt> or
     *         <tt>toElement</tt> lies outside the bounds of the range
     */
    SortedSet<E> subSet(E fromElement, E toElement);

    /**
     * 获取严格小于toElement的子集
     *
     * @param toElement high endpoint (exclusive) of the returned set
     * @return a view of the portion of this set whose elements are strictly
     *         less than <tt>toElement</tt>
     * @throws ClassCastException if <tt>toElement</tt> is not compatible
     *         with this set‘s comparator (or, if the set has no comparator,
     *         if <tt>toElement</tt> does not implement {@link Comparable}).
     *         Implementations may, but are not required to, throw this
     *         exception if <tt>toElement</tt> cannot be compared to elements
     *         currently in the set.
     * @throws NullPointerException if <tt>toElement</tt> is null and
     *         this set does not permit null elements
     * @throws IllegalArgumentException if this set itself has a
     *         restricted range, and <tt>toElement</tt> lies outside the
     *         bounds of the range
     */
    SortedSet<E> headSet(E toElement);

    /**
     * 获取大于等于fromElement的子集
     *
     * @param fromElement low endpoint (inclusive) of the returned set
     * @return a view of the portion of this set whose elements are greater
     *         than or equal to <tt>fromElement</tt>
     * @throws ClassCastException if <tt>fromElement</tt> is not compatible
     *         with this set‘s comparator (or, if the set has no comparator,
     *         if <tt>fromElement</tt> does not implement {@link Comparable}).
     *         Implementations may, but are not required to, throw this
     *         exception if <tt>fromElement</tt> cannot be compared to elements
     *         currently in the set.
     * @throws NullPointerException if <tt>fromElement</tt> is null
     *         and this set does not permit null elements
     * @throws IllegalArgumentException if this set itself has a
     *         restricted range, and <tt>fromElement</tt> lies outside the
     *         bounds of the range
     */
    SortedSet<E> tailSet(E fromElement);

    /**
     * 第一个元素
     *
     * @return the first (lowest) element currently in this set
     * @throws NoSuchElementException if this set is empty
     */
    E first();

    /**
     * 最后一个元素
     *
     * @return the last (highest) element currently in this set
     * @throws NoSuchElementException if this set is empty
     */
    E last();
}
时间: 2024-12-26 00:33:08

SortedSet接口源码解析的相关文章

Deque接口源码解析

Deque 双向队列 队头:可以插入可以删除 队尾:可以插入可以删除 继承Queue接口 源码如下: package java.util; public interface Deque<E> extends Queue<E> { /** * 队头插入元素 * * @throws 队列满了添加元素,抛出:IllegalStateException * @throws 类型不兼容,抛出:ClassCastException * @throws null队列不允许null,抛出:Null

Set接口源码解析

Set 无须集合 元素不可以重复 接口内源码和上面其他接口很类似 package java.util; public interface Set<E> extends Collection<E> { int size(); boolean isEmpty(); boolean contains(Object o); Iterator<E> iterator(); Object[] toArray(); <T> T[] toArray(T[] a); bool

Queue接口源码解析

队列 先进先出 入队列:offer 出队列:poll 队头元素:peek 继承:Collection抽象类 源码如下: package java.util; public interface Queue<E> extends Collection<E> { /** * 队列插入元素 * * @param e the element to add * @return <tt>true</tt> (as specified by {@link Collectio

Map接口源码解析

Map 每个数据项是key-value数据对 key不能重复 接口内代码比较少,都是基本操作 package java.util; public interface Map<K,V> { // Query Operations int size(); boolean isEmpty(); boolean containsKey(Object key); boolean containsValue(Object value); V get(Object key); // Modification

ceph RGW接口源码解析--Rados数据操作

RGW业务处理流程: http reqest --> apache 转 FastCgi module FastCgi module --> radosgw  通过socket请求实现(未确定是否有其它方式) radosgw --> ceph集群  通过socket实现,调用rados接口 1.数据结构 在Rgw_common.h定义了基本的数据结构,并实现了 decode.encode序列化,方便对rados访问 //桶的权限创建资料 struct RGWBucketInfo  {  r

SortedMap接口源码解析

TreeMap的父接口 package java.util; public interface SortedMap<K,V> extends Map<K,V> { Comparator<? super K> comparator(); SortedMap<K,V> subMap(K fromKey, K toKey); SortedMap<K,V> headMap(K toKey); SortedMap<K,V> tailMap(K

Spring-cloud &amp; Netflix 源码解析:Eureka 服务注册发现接口 ****

http://www.idouba.net/spring-cloud-source-eureka-client-api/?utm_source=tuicool&utm_medium=referral *************************** 先关注下netflix eureka server 原生提供的接口.https://github.com/Netflix/eureka/wiki/Eureka-REST-operations 这是对非java的服务使用eureka时可以使用的r

IdentityServer4源码解析_4_令牌发放接口

目录 identityserver4源码解析_1_项目结构 identityserver4源码解析_2_元数据接口 identityserver4源码解析_3_认证接口 identityserver4源码解析_4_令牌发放接口 identityserver4源码解析_5_查询用户信息接口 identityserver4源码解析_6_结束会话接口 identityserver4源码解析_7_查询令牌信息接口 identityserver4源码解析_8_撤销令牌接口 协议 Token接口 oidc服

IdentityServer4源码解析_5_查询用户信息接口

目录 IdentityServer4源码解析_1_项目结构 IdentityServer4源码解析_2_元数据接口 IdentityServer4源码解析_3_认证接口 IdentityServer4源码解析_4_令牌发放接口 IdentityServer4源码解析_5_查询用户信息接口 [IdentityServer4源码解析_6_结束会话接口] [IdentityServer4源码解析_7_查询令牌信息接口] [IdentityServer4源码解析_8_撤销令牌接口] 协议简析 UserI