Ejemplo n.º 1
0
//add an element, make sure it is not full, if it is call expand funciton
void SandwichList::enqueue(const Order & sw)
{
    if (capacity == size()) {
//	cerr << "start expand" << endl;
	expandList();
    }


//    cerr << "check expand" << endl;
    cerr << "front: " << front << " back: " << back << endl;

    orders[back] = sw;
    orderCount++;

    cerr << "insert" << endl;

    if (back >= capacity - 1)
	back = 0;	
    else 
	back++;

    cerr << "capacity: " << capacity << " and Size:" << orderCount << endl;
    cerr << "front: " << front << " back: " << back << endl << endl;

    if (back == front)
	expandList();
}
Ejemplo n.º 2
0
//add an element, make sure it is not full, if it is call expand funciton
void SandwichList::add(const Order& sw)
{
	Order temp = sw;
	
	if(front == back){
		expandList();
	}

	orders[back] = temp;
	back++;
	back = back % capacity;
}
//add an element, make sure it is not full, if it is call expand funciton
void SandwichList::enqueue(const Order& sw)
{
	if(orderCount == capacity){
		expandList();
		back = (back+1)%capacity;
		orderCount = orderCount++;

	}

// TODO: Students write code here
	
}
Ejemplo n.º 4
0
  /* Does: adds a Order to the back of the queue
   * Arguments: reference to an Order 
   * Returns: none
   * Calls: SandwichList.expandList()
   * Notes:	Since back is incremented before copying, back must
   *  start at -1 in the constructor.
   */
void SandwichList::add(const Order& sw){
  if(back == listSize - 1)
    expandList();
    
  orders[++back] = sw;
}