



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Sussman; Class: PROG LANG TECH & PDGMS; Subject: Computer Science; University: University of Maryland; Term: Unknown 1989;
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




CMCS 433, Spring 2002 - Alan Sussman 2
CMCS 433, Spring 2002 - Alan Sussman 3
CMCS 433, Spring 2002 - Alan Sussman 5
public class FixedStack { Object [] array; int top = 0; class MyEnum implements java.util.Enumerator { int count = top; public boolean hasMoreElements() { return count > 0; } public Object nextElement() { if (count == 0) throw new NoSuchElementException(āFixedStackā); return array[--count]; } } public java.util.Enumerator enumerateAll() { return new MyEnum(); } } CMCS 433, Spring 2002 - Alan Sussman 6
CMCS 433, Spring 2002 - Alan Sussman 7
public class FixedStack { Object [] array; int top = 0; public java.util.Enumerator enumerateOldestK(final int k) { class MyEnum implements java.util.Enumerator { int pos = 0; public boolean hasMoreElements () { return pos < k && pos < top; } public Object nextElement() { if (!hasMoreElements()) { throw new NoSuchElementException(āFixedStackā); return array[pos++]; } } return new MyEnum(); } } CMCS 433, Spring 2002 - Alan Sussman^8
public class FixedStack { Object [] array; int top = 0; public java.util.Enumerator enumerateOldestK(final int k) { return new java.util.Enumerator() { int pos = 0; public boolean hasMoreElements() { return pos < k && pos < top; } public Object nextElement() { if (!hasMoreElements()) throw new NoSuchElementException(āFixedStackā); return array[pos++]; } } } }
CMCS 433, Spring 2002 - Alan Sussman 9
CMCS 433, Spring 2002 - Alan Sussman 11
CMCS 433, Spring 2002 - Alan Sussman 12
CMCS 433, Spring 2002 - Alan Sussman 19
CMCS 433, Spring 2002 - Alan Sussman 20
CMCS 433, Spring 2002 - Alan Sussman 21
CMCS 433, Spring 2002 - Alan Sussman 23
CMCS 433, Spring 2002 - Alan Sussman 24
CMCS 433, Spring 2002 - Alan Sussman 25
CMCS 433, Spring 2002 - Alan Sussman 26
CMCS 433, Spring 2002 - Alan Sussman 27