COMP 202 Lecture Notes - Lecture 29: Amay
jc123 and 40170 others unlocked
100
COMP 202 Full Course Notes
Verified Note
100 documents
Document Summary
Data structures: array, linkedlist, arraylist, object. Array (and arraylist) indexing: in an array, all values are accessed via (positive) integer indices. Hashmap indexing: a structure that allows you to index other data types. Hashmaps: structures providing an unordered set of values. Indexed by a key whose type is whatever you want. The first element in the <> denotes the type of the key and 2nd element denotes type of the value. Adds a value to the hashmap and associates it with a specific key: get(key) Return the value associated with the corresponding key: containskey(key) Returns whether or not the hashmap contains the key: containsvalue(value) returns whether or not the hashmap contains the value, remove(key) removes the key-value pair from the map, size() Returns the number of key-value pairs in the hashmap: keyset() Returns a set view of the keys contained in this map. Printing all items in a hashmap: using a for-each loop, converting to an array, using tostring();