Skip to content

Package: IReadOnlyDictionary

IReadOnlyDictionary

Coverage

1: package de.fhdw.gaming.ipspiel23.c4.collections;
2:
3: import java.util.Collection;
4:
5: /**
6: * Represents a generic read-only collection of key/value pairs.
7: *
8: * @param <TKey> The type of keys in the read-only dictionary.
9: * @param <TValue> The type of values in the read-only dictionary.
10: */
11: public interface IReadOnlyDictionary<TKey, TValue> {
12:
13: /**
14: * Determines whether the read-only dictionary contains an element that has the specified key.
15: *
16: * @param key The key to locate.
17: * @return {@code true} if the read-only dictionary contains an element that has the specified key;
18: * otherwise, {@code false}.
19: */
20: boolean containsKey(TKey key);
21:
22: /**
23: * Tries to get the value associated with the specified key in the dictionary.
24: *
25: * @param key The key of the value to get.
26: * @return A {@code TValue} instance. When the method is successful, the returned object is the value associated
27: * with the specified {@code key}. When the method fails, it returns the default value for {@code TValue}.
28: */
29: TValue getValueOrDefault(TKey key);
30:
31: /**
32: * Gets the number of key/value pairs contained in the read-only dictionary.
33: *
34: * @return The number of key/value pairs contained in the read-only dictionary.
35: */
36: int count();
37:
38: /**
39: * Gets a collection containing the keys in the read-only dictionary.
40: *
41: * @return A collection containing the keys in the read-only dictionary.
42: */
43: Collection<TKey> getKeys();
44:
45: /**
46: * Gets a collection containing the values in the read-only dictionary.
47: *
48: * @return A collection containing the values in the read-only dictionary.
49: */
50: Collection<TValue> getValues();
51: }