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)
    • 方法详细资料

      • newHashMap

        public static <K,V> HashMap<K,V> newHashMap()
        Creates a mutable, empty HashMap instance.

        Note: if mutability is not required, use ImmutableMap.of() instead.

        Note: if K is an enum 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, empty TreeMap 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 a HashMap instance, with a high enough "initial capacity" that it should hold expectedSize 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 hold expectedSize entries without resizing
        抛出:
        IllegalArgumentException - if expectedSize is negative
      • newLinkedHashMap

        public static <K,V> LinkedHashMap<K,V> newLinkedHashMap()
        Creates a mutable, empty, insertion-ordered LinkedHashMap 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 a LinkedHashMap instance, with a high enough "initial capacity" that it should hold expectedSize 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 hold expectedSize entries without resizing
        抛出:
        IllegalArgumentException - if expectedSize is negative
        从以下版本开始:
        19.0

Copyright © 2018–2021 Alibaba Group. All rights reserved.