Skip to content

Consistently implement Iterable<T> #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/java/simpledb/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @Threadsafe
*/
public class Catalog {
public class Catalog implements Iterable<Integer> {

/**
* Constructor.
Expand Down Expand Up @@ -90,7 +90,10 @@ public String getPrimaryKey(int tableid) {
return null;
}

public Iterator<Integer> tableIdIterator() {
/**
* Returns an Iterator over the table IDs in this Catalog.
*/
public Iterator<Integer> iterator() {
// some code goes here
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/java/simpledb/HeapPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @see BufferPool
*
*/
public class HeapPage implements Page {
public class HeapPage implements Page, Iterable<Tuple> {

final HeapPageId pid;
final TupleDesc td;
Expand Down
4 changes: 2 additions & 2 deletions src/java/simpledb/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* specified schema specified by a TupleDesc object and contain Field objects
* with the data for each field.
*/
public class Tuple implements Serializable {
public class Tuple implements Serializable, Iterable<Field> {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -91,7 +91,7 @@ public String toString() {
* @return
* An iterator which iterates over all the fields of this tuple
* */
public Iterator<Field> fields()
public Iterator<Field> iterator()
{
// some code goes here
return null;
Expand Down
2 changes: 1 addition & 1 deletion src/java/simpledb/TupleDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/**
* TupleDesc describes the schema of a tuple.
*/
public class TupleDesc implements Serializable {
public class TupleDesc implements Serializable, Iterable<TDItem> {

/**
* A help class to facilitate organizing the information of each field
Expand Down