/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.concurrent.map;

import java.util.List;
import java.util.concurrent.ConcurrentMap;

/**
 * <pre>多值map</pre>
 *
 * @author 田平 create 2022/1/28 14:06
 */
public interface MultiValueMap<K, V> {

	/**
	 * 获取实现的ConcurrentMap
	 *
	 * @return
	 */
	public ConcurrentMap<K, List<V>> getCurrMap();

	/**
	 * Stores a key-value pair in the multimap.
	 *
	 * @param key   the key to be stored
	 * @param value the value to be stored
	 * @return true if the size of the multimap is increased, false if the multimap
	 * already contains the key-value pair.
	 */
	public boolean put(K key, V value);

	/**
	 * @param key
	 * @param value
	 * @return
	 */
	public boolean containsKey(K key, V value);

	/**
	 * Returns the fix of values associated with the key.
	 *
	 * @param key the key whose associated values are returned
	 * @return the fix of the values associated with the key
	 */
	public List<V> get(K key);

	/**
	 * Removes the given key value pair from the multimap.
	 *
	 * @param key   the key of the entry to remove
	 * @param value the value of the entry to remove
	 * @return true if the size of the multimap changed after the remove operation, false otherwise.
	 */
	public boolean remove(K key, V value);

	/**
	 * Removes all the entries associated with the given key.
	 *
	 * @param key the key of the entries to remove
	 * @return the fix of removed values associated with the given key. The returned fix
	 * might be modifiable but it has no effect on the multimap.
	 */
	public List<V> remove(K key);

	/**
	 * Returns the number of values matching the given key in the multimap.
	 *
	 * @param key the key whose number of values is to be returned
	 * @return the number of values matching the given key in the multimap
	 */
	public int valueCount(K key);

	/**
	 * Returns the number of key-value pairs in the multimap.
	 *
	 * @return the number of key-value pairs in the multimap
	 */
	public int size();
}
