Refactor MassiveForceHashMap

This commit is contained in:
2022-05-06 22:45:56 +02:00
parent 6b1f1ecc2a
commit e7eae474ac

View File

@ -1,72 +1,80 @@
// A hash map that associates a 'Massive'-object with a Vector3 (typically this is the force /**
// exerted on the object). The number of key-value pairs is not limited. * A hash map that associates a 'Massive'-object with a Vector3 (typically this is the force
// * exerted on the object). The number of key-value pairs is not limited.
*/
public class MassiveForceHashMap { public class MassiveForceHashMap {
// TODO: define missing parts of this class. // TODO: define missing parts of this class.
// Initializes 'this' as an empty map. /**
* Initializes 'this' as an empty map.
*/
public MassiveForceHashMap() { public MassiveForceHashMap() {
// TODO: implement constructor. // TODO: implement constructor.
} }
// Adds a new key-value association to this map. If the key already exists in this map, /**
// the value is replaced and the old value is returned. Otherwise 'null' is returned. * Adds a new key-value association to this map. If the key already exists in this map,
// Precondition: key != null. * the value is replaced and the old value is returned. Otherwise 'null' is returned.
* Precondition: key != null.
*/
public Vector3 put(Massive key, Vector3 value) { public Vector3 put(Massive key, Vector3 value) {
// TODO: implement method. // TODO: implement method.
return null; return null;
} }
// Returns the value associated with the specified key, i.e. the method returns the force vector /**
// associated with the specified key. Returns 'null' if the key is not contained in this map. * Returns the value associated with the specified key, i.e. the method returns the force vector
// Precondition: key != null. * associated with the specified key. Returns 'null' if the key is not contained in this map.
* Precondition: key != null.
*/
public Vector3 get(Massive key) { public Vector3 get(Massive key) {
// TODO: implement method. // TODO: implement method.
return null; return null;
} }
// Returns 'true' if this map contains a mapping for the specified key. /**
* Returns 'true' if this map contains a mapping for the specified key.
*/
public boolean containsKey(Massive key) { public boolean containsKey(Massive key) {
// TODO: implement method. // TODO: implement method.
return false; return false;
} }
// Returns a readable representation of this map, with all key-value pairs. Their order is not /**
// defined. * Returns a readable representation of this map, with all key-value pairs. Their order is not
* defined.
*/
public String toString() { public String toString() {
// TODO: implement method. // TODO: implement method.
return ""; return "";
} }
// Compares `this` with the specified object for equality. Returns `true` if the specified /**
// `o` is not `null` and is of type `MassiveForceHashMap` and both `this` and `o` have equal * Compares `this` with the specified object for equality. Returns `true` if the specified
// key-value pairs, i.e. the number of key-value pairs is the same in both maps and every * `o` is not `null` and is of type `MassiveForceHashMap` and both `this` and `o` have equal
// key-value pair in `this` equals one key-value pair in `o`. Two key-value pairs are * key-value pairs, i.e. the number of key-value pairs is the same in both maps and every
// equal if the two keys are equal and the two values are equal. Otherwise `false` is returned. * key-value pair in `this` equals one key-value pair in `o`. Two key-value pairs are
* equal if the two keys are equal and the two values are equal. Otherwise, `false` is returned.
*/
public boolean equals(Object o) { public boolean equals(Object o) {
// TODO: implement method. // TODO: implement method.
return false; return false;
} }
// Returns the hashCode of `this`. /**
* Returns the hashCode of `this`.
*/
public int hashCode() { public int hashCode() {
//TODO: implement method. //TODO: implement method.
return 0; return 0;
} }
// Returns a list of all the keys in no specified order. /**
* Returns a list of all the keys in no specified order.
*/
public MassiveLinkedList keyList() { public MassiveLinkedList keyList() {
// TODO: implement method. // TODO: implement method.
return null; return null;
} }
}
}