Beispiel #1
0
 /**
  * This method takes a movie from the top of the queue by the priority it was added and send it to
  * the home queue.
  *
  * @pre the waiting queue must not be empty
  * @post the correct movie will be dequeued from the waiting queue and enqueued in the home queue
  */
 public void sendMovieHomeByPriority() {
   Movie m = waitingQueue.dequeueByPriority();
   if (m == null) {
     return;
   }
   atHomeQueue.enqueue(m);
 }
Beispiel #2
0
	for(int i = 0; i < 100; i++){
	    String s = "" + i;
	    s.push(s);
	    myS.push(s);
	    q.enqueue(s);
	    myQ.enqueue(s);
	}
Beispiel #3
0
  /**
   * return a COPY of solution. This should be : [x1,y1,x2,y2,x3,y3...] the coordinates of the
   * solution from start to end. Precondition : one of the solveXXX methods has already been called
   * (solveBFS OR solveDFS OR solveAStar) (otherwise an empty array is returned) Postcondition: the
   * correct solution is in the returned array
   */
  public int[] solutionCoordinates() {
    MyQueue<Integer> listOfInts = new MyQueue<Integer>();
    Node current = placesToGo.next();
    while (current != null) {
      listOfInts.enqueue(current.getValue()[0]);
      listOfInts.enqueue(current.getValue()[1]);
      current = current.getPrev();
    }

    solution = new int[listOfInts.size()];
    for (int i = 0; i < solution.length; i++) {
      solution[i] = listOfInts.dequeue();
    }

    return solution;
  }
Beispiel #4
0
 public void add(T element) {
   frontier.enqueue(element);
 }