首页 > 其他分享 >Set&List&Map

Set&List&Map

时间:2023-11-09 19:44:39浏览次数:89  
标签:Map Set map List elements key interface

Map

概述

An object that maps keys to values.
A map cannot contain duplicate keys; each key can map to at most one value.

Map将key映射到value;

Map的key不能重复每个key只能映射一个value


This interface takes the place of the <tt>Dictionary</tt> class, which was a totally abstract class rather than an interface.

Map替代了Dictionary;


The <tt>Map</tt> interface provides three <i>collection views</i>, which allow a map's contents to be viewed as a set of keys, collection of values, or set of key-value mappings.
The <i>order</i> of a map is defined as the order in which the iterators on the map's collection views return their elements.
Some map implementations, like the <tt>TreeMap</tt> class, make specific guarantees as to their order; others, like the <tt>HashMap</tt> class, do not.

Map提供3个views:key的Set集合、value的集合、k-v映射集合;

Map的实现:TreeMap(保证有序)、HashMap;

 

All general-purpose map implementation classes should provide two "standard" constructors:
a void (no arguments) constructor which creates an empty map, and a constructor with a single argument of type <tt>Map</tt>, which creates a new map with the same key-value mappings as its argument.
In effect, the latter constructor allows the user to copy any map, producing an equivalent map of the desired class.

Map实现类应该提供2个构造参数:

一个无参构造(创建空Map)、一个Map参数(创建与参数相同k-v的Map);

 

public interface Map<K,V> {


}

  

Set

概述

A collection that contains no duplicate elements.
More formally, sets contain no pair of elements <code>e1</code> and <code>e2</code> such that <code>e1.equals(e2)</code>, and at most one null element.
As implied by its name, this interface models the mathematical <i>set</i> abstraction.

Set不包含重复元素

Set没有e1.equals(e2)的情况,至多一个null

public interface Set<E> extends Collection<E> {

    Iterator<E> iterator();

}

  

  

List

概述

An ordered collection (also known as a <i>sequence</i>).
The user of this interface has precise control over where in the list each element is inserted.
The user can access elements by their integer index (position in the list), and search for elements in the list.

List是一个有序集合


Unlike sets, lists typically allow duplicate elements.
More formally, lists typically allow pairs of elements <tt>e1</tt> and <tt>e2</tt> such that <tt>e1.equals(e2)</tt>, and they typically allow multiple null elements if they allow null elements at all.

list允许重复元素

List允许多个null

 

The <tt>List</tt> interface provides a special iterator, called a <tt>ListIterator</tt>, that allows element insertion and replacement, and bidirectional access in addition to the normal operations that the <tt>Iterator</tt> interface provides.
A method is provided to obtain a list iterator that starts at a specified position in the list.

List提供了一个特殊的iterator(ListIterator允许)

 

public interface List<E> extends Collection<E> {

    Iterator<E> iterator();
    ListIterator<E> listIterator();

}

  

 

标签:Map,Set,map,List,elements,key,interface
From: https://www.cnblogs.com/anpeiyong/p/17822637.html

相关文章

  • 记录--vue3 setup 中国省市区三级联动options最简洁写法,无需任何库
    这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助在写页面的时候,发现表单里面有一个省市区的options组件要写,因为表单很多地方都会用到这个地址选择,我便以为很简单嘛。虽然很简单的一个功能,但是网络上能搜索到的教程大多都是需要配合elementUI等各种UI库的......
  • Flink(三):无状态转换map() 和flatMap()
    一、简介算子map()和flatMap()是用于实现无状态转换的基本操作。二、map()map()算子接收一个MapFunction接口参数,对元素进行一对一转换,即每个元素对应恰好一个结果。由于MapFunction是函数式接口,因此可以使用Lambda表达式。代码如下:StreamExecutionEnvironmentenv......
  • /proc/pids/smaps
    Linux内存管理--/proc/{pid}/smaps讲解基本介绍/proc/PID/smaps文件是基于/proc/PID/maps的扩展,他展示了一个进程的内存消耗,比同一目录下的maps文件更为详细。值得说明一下的是,每一个VMA(虚拟内存区域,即一个vm_area_struct结构指向的内存区域)都有如下的一系列数据:08048......
  • SuperMap-WebGL-S3MTilesLayer(图元操作)
    S3MTilesLayer,S3M(Spatial3DModel)图层类,通过该图层实现加载三维切片缓存,包括倾斜摄影模型、BIM模型、点云数据、精细模型、矢量数据、符号等。那S3MTilesLayer中针对图元的操作主要有'颜色','偏移','可见性'等,可通过下面这张表格,查看对应的方法,文章接下来就从这3个操作来进行说......
  • 开发时推荐使用Map map = new HashMap()
    Mapmap=newHashMap();Map是一个接口,HashMap是具体的实现类。由于接口就是多个类的共有规范(里面的抽象方法),是一种引用数据类型,一个抽象的概念,不能被实例化,因此接口需要由具体的类来实现。这条代码指明:由HashMap类来实现接口Map中描述的方法。HashMapmap=newHashMap(......
  • 无涯教程-批处理 - For 语句 - List Implementations函数
    "for"构造为批处理文件提供循环功能,以下是用于处理值列表的"for"语句的常见结构。FOR%%variableINlistDOdo_something经典的"for"语句由以下部分组成-variable变量    -对于整个循环,此步骤仅执行一次,并用于声明将在循环中使用的任何变量,在批处理脚本中变量声......
  • 'ddlCities' has a SelectedValue which is invalid because it does not exist in th
    this.ddlCities.DataSource=GetAll_List();this.ddlCities.DataTextField="Name";this.ddlCities.DataValueField="Id";this.ddlCities.DataBind();错误:'ddlCities'hasaSelectedValuewhichisinvalidbecauseitdoe......
  • vue2项目使用vueAMap
    npminstallvue-amap-D在main.jsimportVueAMapfrom"vue-amap";Vue.use(VueAMap);VueAMap.initAMapApiLoader({key:"高德地图的key",//这里写你申请的高德地图的keyplugin:["AMap.Autocomplete","AMap.Geocoder","AMap.Geol......
  • No MyBatis mapper was found in ‘[SpringBoot启动类所在路径]‘ package 原因解析及
    NoMyBatismapperwasfoundin‘[SpringBoot启动类所在路径]‘package原因解析及解决方案NoMyBatismapperwasfoundin'[XXX]'package友情提示:搜到这篇文章的,一般是急于解决这个问题的,看下常见原因排除后,可以忽略分析过程直接看解决方案,我自己出现这个问题的原因主......
  • Set---HashSet-LinkedHashSet
    概述Hashtableandlinkedlistimplementationofthe<tt>Set</tt>interface,withpredictableiterationorder.Thisimplementationdiffersfrom<tt>HashSet</tt>inthatitmaintainsadoubly-linkedlistrunningthroughallofitsen......