com.jake
Class MysteryDataStructure<T extends java.lang.Comparable<? super T>>

java.lang.Object
  extended by com.jake.MysteryDataStructure<T>
All Implemented Interfaces:
Collection12<T>

public class MysteryDataStructure<T extends java.lang.Comparable<? super T>>
extends java.lang.Object
implements Collection12<T>

A mystery data structure that acts as a general-purpose container. The "underlying data structure" may be any one of:

The class identity of the underlying data structure is purposely obscured from the user.

Users cannot instantiate objects of this class directly. Instead, they should call the static method getMysteryDataStructure and specify their username, the index of the desired data structure (typically 0-4 inclusive), as well as a "prototype" object indicating what kind of generic container they wish to instantiate.


Method Summary
 void add(T data)
          Adds the specified object to the container.
 void clear()
          Removes all elements from the collection.
 boolean contains(T data)
          Returns whether the specified object is stored in the collection.
static
<T extends java.lang.Comparable<? super T>>
Collection12<T>
getMysteryDataStructure(java.lang.String cs12UserID, int dataStructureNum, T sample)
          Returns a MysteryDataStructure object of the specified index (0-4 for this assignment) for the specified user for the specified type.
 void remove(T data)
          Removes the specified object from the container.
 int size()
          Returns the number of data currently stored in the collection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMysteryDataStructure

public static <T extends java.lang.Comparable<? super T>> Collection12<T> getMysteryDataStructure(java.lang.String cs12UserID,
                                                                                                  int dataStructureNum,
                                                                                                  T sample)
Returns a MysteryDataStructure object of the specified index (0-4 for this assignment) for the specified user for the specified type. The type is specified by supplying a "sample" of the kind of object the MysteryDataStructure should store. For instance, if the user wishes for this method to return a MysteryDataStructure<Integer>, then he/she should pass new Integer(0) as the last parameter.

Parameters:
cs12UserID - the CSE 12 user ID (e.g., cs12vzz) of the student.
dataStructureNum - an index specifying which data structure (typically between 0 and 4) the user wishes to instantiate.
sample - a "prototype" object specifying the kind of data the mystery data structure should store.

add

public void add(T data)
Description copied from interface: Collection12
Adds the specified object to the container. data cannot be null.

Specified by:
add in interface Collection12<T extends java.lang.Comparable<? super T>>
Parameters:
data - the object to add to the collection.

remove

public void remove(T data)
Description copied from interface: Collection12
Removes the specified object from the container. If data is not contained in the collection, then this method does nothing.

Specified by:
remove in interface Collection12<T extends java.lang.Comparable<? super T>>
Parameters:
data - the object to remove from the collection.

contains

public boolean contains(T data)
Description copied from interface: Collection12
Returns whether the specified object is stored in the collection.

Specified by:
contains in interface Collection12<T extends java.lang.Comparable<? super T>>
Parameters:
data - the object whose presence in the collection is being queried.
Returns:
whether the specified object is stored in the collection.

clear

public void clear()
Description copied from interface: Collection12
Removes all elements from the collection.

Specified by:
clear in interface Collection12<T extends java.lang.Comparable<? super T>>

size

public int size()
Description copied from interface: Collection12
Returns the number of data currently stored in the collection.

Specified by:
size in interface Collection12<T extends java.lang.Comparable<? super T>>
Returns:
the number of data currently stored in the collection.