/* * Phase A * Phase B */ package pmap.phasea; /** * PMap stands for Paired Map. A map is a collection of key-value * pairs, e.g., (1, 2) (2, 3) (3, 4) are all pairs with an integer key * and an integer value. See the * * java.util.Map documentation for how these methods are supposed * to work. */ public class PMap { values[index] = val /** * Returns the number of key-value mappings in this map. * * @return the number of key-value mappings in this map */ public Integer size() { // TODO return 0; } /** * Returns true if this map contains no key-value * mappings. * * @return true if this map contains no key-value * mappings */ public boolean isEmpty() { // TODO return false; } /** * Returns true if this map contains a mapping for the * specified key. * * @param key key whose presence in this map is to be tested * @return true if this map contains a mapping for the * specified key */ public boolean containsKey(Integer key) { // TODO return false; } /** * Returns true if this map maps one or more keys to the * specified value. * * @param value value whose presence in this map is to be tested * @return true if this map maps one or more keys to the * specified value */ public boolean containsValue(Integer value) { // TODO return false; } /** * Returns the value to which the specified key is mapped, or * {@code null} if this map contains no mapping for the key. * * @param key the key whose associated value is to be returned * @return the value to which the specified key is mapped, or * {@code null} if this map contains no mapping for the * key */ public Integer get(Integer key) { // TODO return 0; } /** * Associates the specified value with the specified key in this * map (optional operation). If the map previously contained a * mapping for the key, the old value is replaced by the specified * value. * * @param key key with which the specified value is to be * associated * @param value value to be associated with the specified key * @return the previous value associated with key, or * null if there was no mapping for key. */ public Integer put(Integer key, Integer value) { // TODO return 0; } /** * Removes the mapping for a key from this map if it is present * (optional operation). * *

Returns the value to which this map previously associated * the key, or null if the map contained no mapping for * the key. * *

The map will not contain a mapping for the specified key * once the call returns. * * @param key key whose mapping is to be removed from the map * @return the previous value associated with key, or * null if there was no mapping for key. */ public Integer remove(Integer key) { // TODO return 0; } /** * Put all of the mappings from a pair of arrays to this map. Each * pair of elements sharing the same index in keys and * values composes a mapping to be stored the map. * * @param keys the array of keys to be stored in this map * @param values the array of values to be stored in this map */ public void putAll(Integer[] keys, Integer[] values) { // TODO } /** * Removes all of the mappings from this map. The map will be * empty after this call returns. */ public void clear() { // TODO } /** * Returns an array of the keys contained in this map. * * @return an array of the keys contained in this map */ public Integer[] keySet() { // TODO return null; } /** * Returns an array of the values contained in this map. * * @return an array of the values contained in this map */ public Integer[] values() { // TODO return null; } /** * Returns an array of the mappings contained in this map. * * @return an array of the mappings contained in this map */ public PEntry[] entrySet() { // TODO return null; } }