Interface MutableIntObjectMap<V>

    • Method Detail

      • put

        V put​(int key,
              V value)
        Associates a value with the specified key. If a value is already associated with the key in this map, it will be replaced with value.
        Parameters:
        key - the key
        value - the value to associate with value
        Returns:
        the value previously associated with key if one existed, or null if not
      • putPair

        default V putPair​(IntObjectPair<V> keyValuePair)
        This method allows MutableIntObjectMap the ability to add an element in the form of IntObjectPair<V>.
        Since:
        9.1.0
        See Also:
        put(int, Object)
      • putAll

        void putAll​(IntObjectMap<? extends V> map)
        Puts all of the key/value mappings from the specified map into this map. If this map already has a value associated with one of the keys in the map, it will be replaced with the value in map.
        Parameters:
        map - the map to copy into this map
        Since:
        5.0.
      • removeKey

        V removeKey​(int key)
        Removes the mapping associated with the key, if one exists, from the map.
        Parameters:
        key - the key to remove
        See Also:
        remove(int)
      • remove

        V remove​(int key)
        Removes the mapping associated with the key, if one exists, from the map.
        Parameters:
        key - the key to remove
        See Also:
        removeKey(int)
      • getIfAbsentPut

        V getIfAbsentPut​(int key,
                         V value)
        Retrieves the value associated with the key if one exists; if it does not, associates a value with the key.
        Parameters:
        key - the key
        value - the value to associate with key if no such mapping exists
        Returns:
        the value associated with key, if one exists, or value if not
      • getIfAbsentPut

        V getIfAbsentPut​(int key,
                         Function0<? extends V> function)
        Retrieves the value associated with the key if one exists; if it does not, invokes the supplier and associates the result with the key.
        Parameters:
        key - the key
        function - the supplier that provides the value if no mapping exists for key
        Returns:
        the value associated with the key, if one exists, or the result of invoking function if not
      • getIfAbsentPutWithKey

        V getIfAbsentPutWithKey​(int key,
                                IntToObjectFunction<? extends V> function)
        Retrieves the value associated with the key if one exists; if it does not, associates the result of invoking the value function with the key.
        Parameters:
        key - the key
        function - the function that provides the value if no mapping exists. The key will be passed as the argument to the function.
        Returns:
        the value associated with the key, if one exists, or the result of invoking function with key if not
      • getIfAbsentPutWith

        <P> V getIfAbsentPutWith​(int key,
                                 Function<? super P,​? extends V> function,
                                 P parameter)
        Retrieves the value associated with the key if one exists; if it does not, invokes the value function with the parameter and associates the result with the key.
        Type Parameters:
        P - the type of the value function's parameter
        Parameters:
        key - the key
        function - the function that provides the value if no mapping exists. The specified parameter will be passed as the argument to the function.
        parameter - the parameter to provide to function if no value exists for key
        Returns:
        the value associated with the key, if one exists, or the result of invoking function with parameter if not
      • updateValue

        V updateValue​(int key,
                      Function0<? extends V> factory,
                      Function<? super V,​? extends V> function)
        Look up the value associated with key, apply the function to it, and replace the value. If there is no value associated with key, start it off with a value supplied by factory.
      • updateValueWith

        <P> V updateValueWith​(int key,
                              Function0<? extends V> factory,
                              Function2<? super V,​? super P,​? extends V> function,
                              P parameter)
        Updates or sets the value associated with the key by applying the function to the existing value, if one exists, or the initial value supplied by the factory if one does not.
        Type Parameters:
        P - the type of the value function's parameter
        Parameters:
        key - the key
        factory - the supplier providing the initial value to the function if no mapping exists for the key
        function - the function that returns the updated value based on the current value or the initial value, if no value exists. The specified parameter will also be passed as the second argument to the function.
        parameter - the parameter to provide to function if no value exists for key
        Returns:
        the new value associated with the key, either as a result of applying function to the value already associated with the key or as a result of applying it to the value returned by factory and associating the result with key
      • tap

        MutableIntObjectMap<V> tap​(Procedure<? super V> procedure)
        Description copied from interface: RichIterable
        Executes the Procedure for each element in the iterable and returns this.

        Example using a Java 8 lambda expression:

         RichIterable<Person> tapped =
             people.tap(person -> LOGGER.info(person.getName()));
         

        Example using an anonymous inner class:

         RichIterable<Person> tapped =
             people.tap(new Procedure<Person>()
             {
                 public void value(Person person)
                 {
                     LOGGER.info(person.getName());
                 }
             });
         
        Specified by:
        tap in interface IntObjectMap<V>
        Specified by:
        tap in interface RichIterable<V>
        See Also:
        RichIterable.each(Procedure), RichIterable.forEach(Procedure)
      • select

        MutableIntObjectMap<V> select​(IntObjectPredicate<? super V> predicate)
        Description copied from interface: IntObjectMap
        Return a copy of this map containing only the key/value pairs that match the predicate.
        Specified by:
        select in interface IntObjectMap<V>
        Parameters:
        predicate - the predicate to determine which key/value pairs in this map should be included in the returned map
        Returns:
        a copy of this map with the matching key/value pairs
      • reject

        MutableIntObjectMap<V> reject​(IntObjectPredicate<? super V> predicate)
        Description copied from interface: IntObjectMap
        Return a copy of this map containing only the key/value pairs that do not match the predicate.
        Specified by:
        reject in interface IntObjectMap<V>
        Parameters:
        predicate - the predicate to determine which key/value pairs in this map should be excluded from the returned map
        Returns:
        a copy of this map without the matching key/value pairs
      • withKeyValue

        MutableIntObjectMap<V> withKeyValue​(int key,
                                            V value)
        Associates a value with the specified key. If a value is already associated with the key in this map, it will be replaced with value.
        Parameters:
        key - the key
        value - the value to associate with value
        Returns:
        this map
        See Also:
        #put(int, V)
      • withoutKey

        MutableIntObjectMap<V> withoutKey​(int key)
        Removes the mapping associated with the key, if one exists, from this map.
        Parameters:
        key - the key to remove
        Returns:
        this map
        See Also:
        remove(int)
      • withoutAllKeys

        MutableIntObjectMap<V> withoutAllKeys​(IntIterable keys)
        Removes the mappings associated with all the keys, if they exist, from this map.
        Parameters:
        keys - the keys to remove
        Returns:
        this map
        See Also:
        remove(int)
      • withAllKeyValues

        default MutableIntObjectMap<V> withAllKeyValues​(java.lang.Iterable<IntObjectPair<V>> keyValuePairs)
        Puts all of the key/value mappings from the specified pairs into this map. If this map already has a value associated with one of the keys in the pairs, it will be replaced with the value in the pair.
        Parameters:
        iterable - the pairs to put into this map
        Returns:
        this map
        See Also:
        putPair(IntObjectPair)
      • asUnmodifiable

        MutableIntObjectMap<V> asUnmodifiable()
        Returns an unmodifiable view of this map, delegating all read-only operations to this map and throwing an UnsupportedOperationException for all mutating operations. This avoids the overhead of copying the map when calling IntObjectMap.toImmutable() while still providing immutability.
        Returns:
        an unmodifiable view of this map
      • asSynchronized

        MutableIntObjectMap<V> asSynchronized()
        Returns a synchronized view of this map, delegating all operations to this map but ensuring only one caller has access to the map at a time.
        Returns:
        a synchronized view of this map