1 /*
2  * Hunt - A refined core library for D programming language.
3  *
4  * Copyright (C) 2018-2019 HuntLabs
5  *
6  * Website: https://www.huntlabs.net/
7  *
8  * Licensed under the Apache-2.0 License.
9  *
10  */
11 
12 module hunt.collection.MultiValueMap;
13 
14 import hunt.collection.List;
15 import hunt.collection.Map;
16 
17 alias MultiValuesMap(T) = Map!(string, List!(T));
18 alias MultiStringsMap = MultiValuesMap!string;
19 
20 
21 /**
22  * Extension of the {@code Map} interface that stores multiple values.
23  *
24  * @author Arjen Poutsma
25  * @since 3.0
26  */
27 interface MultiValueMap(K, V) : Map!(K, List!(V)) {
28 
29 	/**
30 	 * Return the first value for the given key.
31 	 * @param key the key
32 	 * @return the first value for the specified key, or {@code null} if none
33 	 */	
34 	V getFirst(K key);
35 
36 	/**
37 	 * Add the given single value to the current list of values for the given key.
38 	 * @param key the key
39 	 * @param value the value to be added
40 	 */
41 	void add(K key, V value);
42 
43 	/**
44 	 * Add all the values of the given list to the current list of values for the given key.
45 	 * @param key they key
46 	 * @param values the values to be added
47 	 * @since 5.0
48 	 */
49 	void addAll(K key, List!V values);
50 
51 	/**
52 	 * Add all the values of the given {@code MultiValueMap} to the current values.
53 	 * @param values the values to be added
54 	 * @since 5.0
55 	 */
56 	void addAll(Map!(K, List!V) values);
57 
58 	/**
59 	 * Set the given single value under the given key.
60 	 * @param key the key
61 	 * @param value the value to set
62 	 */
63 	void set(K key, V value);
64 
65 	/**
66 	 * Set the given values under.
67 	 * @param values the values.
68 	 */
69 	void setAll(Map!(K, V) values);
70 
71 	/**
72 	 * Returns the first values contained in this {@code MultiValueMap}.
73 	 * @return a single value representation of this map
74 	 */
75 	Map!(K, V) toSingleValueMap();
76 
77 }