nc界面排序_排序地图界面

nc界面排序

In Java, SortedMap is an interface of Collection framework. SortedMap extends Map interface and also provide the ordering of the elements. Traversing the sorted elements becomes easier.

在Java中,SortedMap是Collection框架的接口。 SortedMap扩展了Map接口,还提供了元素的顺序。 遍历排序的元素变得更加容易。

下面是SortedMap接口的方法。 (Below are the methods of SortedMap Interface.)
S.no.MethodsDescription
1subMap(K fromKey, K toKey)It is used to view the elements from a given range
2headMap(K toKey)It is used to get the key which is less than than the toKey.
3tailMap(K fromKey)It is used to get the key which is greater than or equal to the fromKey.
4firstKey()It is used to get the lowest key.
5lastKey()It is used to get the highest key.
6comparator()It is used to get the comparator used in the Map.
7values()It is used to get the values of the Map
8keySet()It is used to get the set view from the Map.
9entrySet()It is used to get the set view of the mapping which are contained in the map.
序号 方法 描述
1个 subMap(K fromKey,K toKey) 用于查看给定范围内的元素
2 headMap(K toKey) 它用于获取小于toKey的密钥。
3 tailMap(K fromKey) 它用于获取大于或等于fromKey的密钥。
4 firstKey() 它用于获取最低密钥。
5 lastKey() 它用于获取最高密钥。
6 比较器() 它用于获取Map中使用的比较器。
7 values() 用于获取Map的值
8 keySet() 它用于从地图获取设置视图。
9 entrySet() 它用于获取映射中包含的映射的设置视图。

Example:

例:

import java.util.Iterator; 
import java.util.Map; 
import java.util.Set; 
import java.util.SortedMap; 
import java.util.TreeMap; 

public class SortedMapDemo1
{ 
    public static void main(String[] args) 
    { 
SortedMap<Integer, String> a = new TreeMap<Integer, String>(); 
a.put(new Integer(2), "Red"); 
a.put(new Integer(3), "Pink"); 
a.put(new Integer(5), "Yellow"); 
a.put(new Integer(4), "Black"); 
a.put(new Integer(1), "Green"); 
        Set b = a.entrySet(); 
        Iterator i = b.iterator(); 
        while (i.hasNext()) 
        { 
Map.Entry c = (Map.Entry)i.next(); 
int key1 = (Integer)c.getKey(); 
            String value1 = (String)c.getValue(); 
System.out.println("Key : " + key1 + " || value : " + value1); 
        } 
    } 
}
sorted map example

翻译自: https://www.studytonight.com/java/sorted-map-interface.php

nc界面排序

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值