@Override
	public V put(K key, V value) {
		// Find the key
		int elementIndex = findKeyIndex(key);

		// If the key was already in the map, update the value of that entry
		// and return the old value
		if (elementIndex != -1) {
			V oldVal = mapArray[elementIndex].getValue();
			mapArray[elementIndex] = new Pair<>(key, value);
			return oldVal;
		}

		// The key was not present, so we will insert it. Make the map grow
		// in size if need be.
		if (size >= mapArray.length) {
			Entry<K, V>[] newMap = (Entry<K, V>[]) new Entry[mapArray.length * 2];
			System.arraycopy(mapArray, 0, newMap, 0, mapArray.length);
			mapArray = newMap;
		}

		// Insert the new key-value pair into the map and return null
		mapArray[size++] = new Pair<>(key, value);
		return null;
	}