Class ManMapExt


  • public class ManMapExt
    extends Object
    • Constructor Detail

      • ManMapExt

        public ManMapExt()
    • Method Detail

      • set

        public static <K,​V> V set​(Map<K,​V> thiz,
                                        K key,
                                        V value)
        Implements the indexed assignment operator for Map to enable the syntax: map[key] = value

        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
        Throws:
        UnsupportedOperationException - if the put operation is not supported by this map
        ClassCastException - if the class of the specified key or value prevents it from being stored in this map
        NullPointerException - if the specified key or value is null and this map does not permit null keys or values
        IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map
        See Also:
        Map.put(Object, Object)
      • mapOf

        @SafeVarargs
        public static <K,​V> Map<K,​V> mapOf​(manifold.rt.api.util.Pair<K,​V>... entries)
        For use with the key and value binding expression syntax using Pair.and.
        
         import static manifold.rt.api.util.Pair.and;
         Map<String, Integer> scores =
           mapOf("Moe" and 100, "Larry" and 107, "Curly" and 111);
         
        Returns a new read-only map with the specified contents, given as a list of pairs where the first value is the key and the second is the value.

        If multiple pairs have the same key, the resulting map will contain the value from the last of those pairs.

        Entries of the map are iterated in the order they were specified.

        Parameters:
        entries - key/value pairs, for use with the key and value binding expression syntax via Pair.and.
        Returns:
        a new read-only, ordered map with the specified contents.
        Throws:
        UnsupportedOperationException - if the put operation is not supported by this map
        ClassCastException - if the class of the specified key or value prevents it from being stored in this map
        NullPointerException - if the specified key or value is null and this map does not permit null keys or values
        IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map
        See Also:
        Map.put(Object, Object)