Algorithms and OOD (CSC 207 2013F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Overview
Admin
char *
foo(char *t, char *s)
{
while (*t++ = *s++)
;
return t;
} // for
Due tonight
Why implement java.util.Iterator when we have cursors?
Real Java programmers build iterators for any collection class they design
public class MyIterator<T> implements java.util.Iterator<T> {
// +--------+----------------------------------------------------------
// | Fields |
// +--------+
Node<T> pos;
// +--------------+----------------------------------------------------
// | Constructors |
// +--------------+
// +---------+---------------------------------------------------------
// | Methods |
// +---------+
public T next() {
// Find out what's right after pos
// Advance the position
// Return the value we got in step 1
}
public boolean hasNext() {
}
public void remove() {
throw new UnsupportedOperationException();
}
}
Once you've implemented iterators, folks can write
DoublyLinkedList dll;
for (val : dll) {
}
_When should I put the type variable in brackets?
Usually, whenever you are referring to a generic/parameterized class.
Not when you are using it as a type
So
public T extractValue(Node<T> node)
Also when parameterizing static methods
public static <T> returnType methodName(...)
Any hints on DNF?
Write
isDNF
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Java 7 API] [Java Code Conventions]
Related Courses: [CSC 152 2006S (Rebelsky)] [CSC 207 2013S (Walker)] [CSC 207 2011S (Weinman)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)] [Issue Tracker (Textbook)]
Copyright (c) 2013 Samuel A. Rebelsky.

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.