src/jdk.internal.vm.compiler/share/classes/org.graalvm.collections/src/org/graalvm/collections/UnmodifiableEconomicMap.java
changeset 48861 47f19ff9903c
equal deleted inserted replaced
48860:5bce1b7e7800 48861:47f19ff9903c
       
     1 /*
       
     2  * Copyright (c) 2017, 2017, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 package org.graalvm.collections;
       
    26 
       
    27 /**
       
    28  * Unmodifiable memory efficient map data structure.
       
    29  *
       
    30  * @since 1.0
       
    31  */
       
    32 public interface UnmodifiableEconomicMap<K, V> {
       
    33 
       
    34     /**
       
    35      * Returns the value to which {@code key} is mapped, or {@code null} if this map contains no
       
    36      * mapping for {@code key}.
       
    37      *
       
    38      * @since 1.0
       
    39      */
       
    40     V get(K key);
       
    41 
       
    42     /**
       
    43      * Returns the value to which {@code key} is mapped, or {@code defaultValue} if this map
       
    44      * contains no mapping for {@code key}.
       
    45      *
       
    46      * @since 1.0
       
    47      */
       
    48     default V get(K key, V defaultValue) {
       
    49         V v = get(key);
       
    50         if (v == null) {
       
    51             return defaultValue;
       
    52         }
       
    53         return v;
       
    54     }
       
    55 
       
    56     /**
       
    57      * Returns {@code true} if this map contains a mapping for {@code key}.
       
    58      *
       
    59      * @since 1.0
       
    60      */
       
    61     boolean containsKey(K key);
       
    62 
       
    63     /**
       
    64      * Returns the number of key-value mappings in this map.
       
    65      *
       
    66      * @since 1.0
       
    67      */
       
    68     int size();
       
    69 
       
    70     /**
       
    71      * Returns {@code true} if this map contains no key-value mappings.
       
    72      *
       
    73      * @since 1.0
       
    74      */
       
    75     boolean isEmpty();
       
    76 
       
    77     /**
       
    78      * Returns a {@link Iterable} view of the values contained in this map.
       
    79      *
       
    80      * @since 1.0
       
    81      */
       
    82     Iterable<V> getValues();
       
    83 
       
    84     /**
       
    85      * Returns a {@link Iterable} view of the keys contained in this map.
       
    86      *
       
    87      * @since 1.0
       
    88      */
       
    89     Iterable<K> getKeys();
       
    90 
       
    91     /**
       
    92      * Returns a {@link UnmodifiableMapCursor} view of the mappings contained in this map.
       
    93      *
       
    94      * @since 1.0
       
    95      */
       
    96     UnmodifiableMapCursor<K, V> getEntries();
       
    97 }