DOC PREVIEW
USC CSCI 455x - Code Handout

Previewing page 1

Save
Premium Document
Do you want full access? Go Premium and unlock all 1 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Code Handout to accompany final exam CSCI 455 [F14 Bono] (C++) Node type and ListType (this is the only part of the code handout with C++ code): struct Node { int data; Node * next; Node() { data = 0; next = NULL; } Node(int d) { data = d; next = NULL; } Node(int d, Node * n) { data = d; next = n; } }; typedef Node * ListType; (Java) Map<KeyType, ValueType> Interface: The classes that implement this interface are: TreeMap and HashMap. Selected methods: ValueType put(key, value) Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced by the specified value. Returns the previous value associated with specified key, or null if there was no mapping for key. ValueType get(key) Returns the value to which this key is mapped or null if the map contains no mapping for this key. ValueType remove(key) Removes the mapping for this key from this map if it is present, otherwise returns null. int size() Number of key-value mappings in this map. boolean isEmpty() Returns true if this map contains no key-value mappings. Set<Map.Entry<KeyType,ValueType>> entrySet() Returns a set view of the entries contained in this map. Set<KeyType> keySet() Returns a set view of the keys contained in this map. (Java) Map.Entry<KeyType, ValueType> Interface Selected methods: KeyType getKey() Return the key of the entry ValueType getValue() Return the value of the entry void setValue(newVal) Replace the current value with newVal (Java) Set<ElmtType> Interface Selected methods: Iterator<ElmtType> iterator() Returns an iterator over the elements in this collection. (Java) Iterator<ElmtType> Interface boolean hasNext() Returns true iff the iteration has more elements. ElmtType next() Returns the next element in the iteration. Each successive call returns a different element in the underlying collection. void remove() Removes from the underlying collection the last element returned by the


View Full Document

USC CSCI 455x - Code Handout

Download Code Handout
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Code Handout and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Code Handout 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?