类 MapUtils
- java.lang.Object
-
- com.alibaba.excel.util.MapUtils
public class MapUtils extends Object
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.- 作者:
- Apache Software Foundation (ASF)
-
方法概要
所有方法 静态方法 具体方法 限定符和类型 方法和说明 static <K,V> HashMap<K,V>
newHashMap()
Creates a mutable, emptyHashMap
instance.static <K,V> HashMap<K,V>
newHashMapWithExpectedSize(int expectedSize)
Creates aHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth.static <K,V> LinkedHashMap<K,V>
newLinkedHashMap()
Creates a mutable, empty, insertion-orderedLinkedHashMap
instance.static <K,V> LinkedHashMap<K,V>
newLinkedHashMapWithExpectedSize(int expectedSize)
Creates aLinkedHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth.static <K extends Comparable,V>
TreeMap<K,V>newTreeMap()
Creates a mutable, emptyTreeMap
instance using the natural ordering of its elements.
-
方法详细资料
newHashMap
public static <K,V> HashMap<K,V> newHashMap()
Creates a mutable, emptyHashMap
instance.Note: if mutability is not required, use ImmutableMap.of() instead.
Note: if
K
is anenum
type, use newEnumMap instead.Note for Java 7 and later: this method is now unnecessary and should be treated as deprecated. Instead, use the
HashMap
constructor directly, taking advantage of the new "diamond" syntax.- 返回:
-
a new, empty
HashMap
newTreeMap
public static <K extends Comparable,V> TreeMap<K,V> newTreeMap()
Creates a mutable, emptyTreeMap
instance using the natural ordering of its elements.Note: if mutability is not required, use ImmutableSortedMap.of() instead.
Note for Java 7 and later: this method is now unnecessary and should be treated as deprecated. Instead, use the
TreeMap
constructor directly, taking advantage of the new "diamond" syntax.- 返回:
-
a new, empty
TreeMap
newHashMapWithExpectedSize
public static <K,V> HashMap<K,V> newHashMapWithExpectedSize(int expectedSize)
Creates aHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.7. It also can't be guaranteed that the method isn't inadvertently oversizing the returned map.- 参数:
-
expectedSize
- the number of entries you expect to add to the returned map - 返回:
-
a new, empty
HashMap
with enough capacity to holdexpectedSize
entries without resizing - 抛出:
-
IllegalArgumentException
- ifexpectedSize
is negative
newLinkedHashMap
public static <K,V> LinkedHashMap<K,V> newLinkedHashMap()
Creates a mutable, empty, insertion-orderedLinkedHashMap
instance.Note: if mutability is not required, use ImmutableMap.of() instead.
Note for Java 7 and later: this method is now unnecessary and should be treated as deprecated. Instead, use the
LinkedHashMap
constructor directly, taking advantage of the new "diamond" syntax.- 返回:
-
a new, empty
LinkedHashMap
newLinkedHashMapWithExpectedSize
public static <K,V> LinkedHashMap<K,V> newLinkedHashMapWithExpectedSize(int expectedSize)
Creates aLinkedHashMap
instance, with a high enough "initial capacity" that it should holdexpectedSize
elements without growth. This behavior cannot be broadly guaranteed, but it is observed to be true for OpenJDK 1.7. It also can't be guaranteed that the method isn't inadvertently oversizing the returned map.- 参数:
-
expectedSize
- the number of entries you expect to add to the returned map - 返回:
-
a new, empty
LinkedHashMap
with enough capacity to holdexpectedSize
entries without resizing - 抛出:
-
IllegalArgumentException
- ifexpectedSize
is negative - 从以下版本开始:
- 19.0
Copyright © 2018–2021 Alibaba Group. All rights reserved.