All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gnu.trove.map.TMap Maven / Gradle / Ivy

Go to download

The Trove library provides high speed regular and primitive collections for Java.

There is a newer version: 3.0.3
Show newest version
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2011, Rob Eden All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////

package gnu.trove.map;

import gnu.trove.function.TObjectFunction;
import gnu.trove.procedure.TObjectObjectProcedure;
import gnu.trove.procedure.TObjectProcedure;

import java.util.Map;


/**
 * Interface extension to {@link Map} which adds Trove-specific features.
 */
public interface TMap extends Map {

    /**
     * Inserts a key/value pair into the map if the specified key is not already
     * associated with a value.
     *
     * @param key   an Object value
     * @param value an Object value
     * @return the previous value associated with key,
     *         or {@code null} if none was found.
     */
    public V putIfAbsent(K key, V value);


    /**
     * Executes procedure for each key in the map.
     *
     * @param procedure a TObjectProcedure value
     * @return false if the loop over the keys terminated because
     *         the procedure returned false for some key.
     */
    public boolean forEachKey(TObjectProcedure procedure);


    /**
     * Executes procedure for each value in the map.
     *
     * @param procedure a TObjectProcedure value
     * @return false if the loop over the values terminated because
     *         the procedure returned false for some value.
     */
    public boolean forEachValue(TObjectProcedure procedure);


    /**
     * Executes procedure for each key/value entry in the
     * map.
     *
     * @param procedure a TObjectObjectProcedure value
     * @return false if the loop over the entries terminated because
     *         the procedure returned false for some entry.
     */
    @SuppressWarnings({"unchecked"})
    public boolean forEachEntry(TObjectObjectProcedure procedure);


    /**
     * Retains only those entries in the map for which the procedure
     * returns a true value.
     *
     * @param procedure determines which entries to keep
     * @return true if the map was modified.
     */
    @SuppressWarnings({"unchecked"})
    public boolean retainEntries(TObjectObjectProcedure procedure);


    /**
     * Transform the values in this map using function.
     *
     * @param function a TObjectFunction value
     */
    public void transformValues(TObjectFunction function);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy