Skip to main content

Student Portal > Contests > 

Programming Contest Central

   
Welcome students Resources Competition ProfilesFAQ
  Contest calendar
  Problem of the month
  Past problems
  Games and brainteasers
  Successes
  Tutorials

Intefaces

/**
 * An interface contains a set of methods that must be implemented.
 * It is a way to ensure that the class that implements it
 * has all the necessary components.
 *
 * If a class wishes to implement the Queue interface, it must
 * have all the methods fully implemented.
 *
 * Below is an example of a Queue interface. (Full implementation can be
 * seen in the ArrayQueue class)
 */
public interface Queue {
 
  /**
   * Enqueues o to the queue.
   * Precondition: isFull() returns false.
   */
  void add(Object o);
 
  /**
   * Remove and return the front element.
   * Precondition: size() != 0
   */
  Object remove();
 
  // Return the size of the queue
  int size();
 
  // Return whether the queue is full or not
  boolean isFull();
 
  // Return whether the queue is empty or not
  boolean isEmpty();
}


Back to top
 


Quick links

Student forum

Teacher resources

RSS Feed