DOC PREVIEW
USC CSCI 455x - Code Handout

This preview shows page 1 out of 2 pages.

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

Unformatted text preview:

Code Handout to accompany final exam CSCI 455 F17 Bono Java Map KeyType ValueType Interface selected methods The classes that implement this interface are TreeMap and HashMap 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 map maps the specified key or null if the map contains no mapping for this key boolean containsKey key Returns true iff the map contains a mapping for the specified 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 Map Entry KeyType ValueType keySet Returns a set view of the keys contained in this map Java Map Entry KeyType ValueType Interface 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 Iterator ElmtType Interface selected methods Some classes that implement this interface are Scanner ListIterator 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 For Scanner the ElmtType is always String continued other side 1 Code Handout to accompany final exam CSCI 455 F17 Bono Java Collection ElmtType Interface selected methods Some classes that implement this interface are ArrayList LinkedList TreeSet and HashSet boolean contains elmt Returns true iff elmt is in this collection int size Returns number of elements in this collection boolean add elmt Ensures that elmt is in this collection Returns true iff this collection changed as a result of this call boolean remove elmt Removes an instance of elmt from this collection Returns true iff this collection changed as a result of this call boolean isEmpty Returns true iff this collection contains no elements Iterator ElmtType iterator Returns an iterator over the elements in this collection C Node type and ListType this is the only part of the code handout with C code struct Node int data Node next Node int item create a Node with the given value and NULL next field create a Node with the given data value item and next field n Node int item Node n typedef Node ListType more other side 2


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 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?