int remove_item_test(void) { clear_queue(); insert_item(42); _assert(front() == 42); _assert(queue_size() == 1); _assert(remove_item() == 42); _assert(queue_size() == 0); _assert(is_empty() == true); insert_item(12); insert_item(13); insert_item(14); _assert(front() == 12); _assert(rear() == 14); _assert(queue_size() == 3); _assert(remove_item() == 12); _assert(front() == 13); _assert(rear() == 14); _assert(queue_size() == 2); _assert(remove_item() == 13); _assert(front() == 14); _assert(rear() == 14); _assert(queue_size() == 1); clear_queue(); return 0; }
void BoundingBoxDoorVisual::generateWireframe() { delete m_wireframe; m_wireframe = new rviz::BillboardLine(m_sceneManager, m_sceneNode); m_wireframe->setLineWidth(m_lineWidth); m_wireframe->setMaxPointsPerLine(2); m_wireframe->setNumLines(12); double w = m_width, h = m_height; Ogre::Vector3 bottomLeft(0, -w, 0), bottomRight(0, 0, 0), topLeft(0, -w, h), topRight(0, 0, h); Ogre::Vector3 rear(m_thickness, 0, 0); // Front quad m_wireframe->addPoint(bottomLeft); m_wireframe->addPoint(bottomRight); m_wireframe->newLine(); m_wireframe->addPoint(bottomRight); m_wireframe->addPoint(topRight); m_wireframe->newLine(); m_wireframe->addPoint(topRight); m_wireframe->addPoint(topLeft); m_wireframe->newLine(); m_wireframe->addPoint(topLeft); m_wireframe->addPoint(bottomLeft); // Rear quad m_wireframe->newLine(); m_wireframe->addPoint(bottomLeft + rear); m_wireframe->addPoint(bottomRight + rear); m_wireframe->newLine(); m_wireframe->addPoint(bottomRight + rear); m_wireframe->addPoint(topRight + rear); m_wireframe->newLine(); m_wireframe->addPoint(topRight + rear); m_wireframe->addPoint(topLeft + rear); m_wireframe->newLine(); m_wireframe->addPoint(topLeft + rear); m_wireframe->addPoint(bottomLeft + rear); // Four connecting lines between front and rear m_wireframe->newLine(); m_wireframe->addPoint(bottomLeft); m_wireframe->addPoint(bottomLeft + rear); m_wireframe->newLine(); m_wireframe->addPoint(bottomRight); m_wireframe->addPoint(bottomRight + rear); m_wireframe->newLine(); m_wireframe->addPoint(topRight); m_wireframe->addPoint(topRight + rear); m_wireframe->newLine(); m_wireframe->addPoint(topLeft); m_wireframe->addPoint(topLeft + rear); m_wireframe->setPosition(Ogre::Vector3(0, 0, 0)); // Ogre::Quaternion orientation; // orientation.FromRotationMatrix(R_do); // m_wireframe->setOrientation(orientation); }
int main() { struct Queue *queue=createQueue(1000); enqueue(queue, 10); enqueue(queue, 20); enqueue(queue, 30); enqueue(queue, 40); printf("%d dequeued from queue\n",dequeue(queue)); printf("Front item is %d \n",front(queue)); printf("Rear item is %d\n",rear(queue)); }
int insert_item_test(void) { clear_queue(); _assert(queue_size() == 0); insert_item(42); _assert(front() == 42); _assert(rear() == 42); _assert(queue_size() == 1); insert_item(10); _assert(front() == 42); _assert(rear() == 10); _assert(queue_size() == 2); insert_item(-1); _assert(front() == 42); _assert(rear() == -1); _assert(queue_size() == 3); clear_queue(); return 0; }
int main(void) { Queue q = create_queue(37); insert_item(q, 2); assert(remove_item(q) == 2); assert(is_empty(q) == true); printf("This should exit with a failure.\n\n"); /* remove_item(q); */ front(q); rear(q); return 0; }
int main() { int choice; int num; // create Queue printf("Please insert a number for queue size \n"); scanf("%d", &choice); Queue *Q = createQueue(choice); printf("Queue is created!\n\n"); while (1) { printf("1.Enqueue \n"); printf("2.Dequeue \n"); printf("3.Queue Front \n"); printf("4.Queue Rear \n"); printf("5.Quit \n"); printf("Enter your choice : "); scanf("%d", &choice); switch (choice) { case 1: printf("Enter your number to be put into queue : "); scanf("%d", &num); Enqueue(Q,num); printf("----------------------------------------\n\n"); break; case 2: Dequeue(Q); printf("----------------------------------------\n\n"); break; case 3: printf("Front element is %d\n",front(Q)); printf("----------------------------------------\n\n"); break; case 4: printf("Rear element is %d\n",rear(Q)); printf("----------------------------------------\n\n"); break; case 5: exit(1); default: printf("Wrong choice \n"); } /*End of switch*/ } /*End of while*/ } /*End of main()*/
int main(void) { int capacity; scanf("%d", &capacity); struct queue * q; q = create (capacity); printf("1.enqueue\n2.dequeue\n3.front\n4.rear\n5.isempty\n6.isfull\n7.end\n"); int end; int test; int num; end = 1; while (end) { scanf("%d", &test); switch (test){ case 1: scanf("%d", &num); enqueue(q, num); break; case 2: num = dequeue(q); if (num == -1) { printf("Underflow\n)"); } else { printf("%d\n",num); } break; case 3: num = front(q); if (num != -1) { printf("%d\n", num); } break; case 4: num = rear(q); if (num != -1) { printf("%d\n", num); } break; case 5: num = isempty(q); if (num == 0) { printf("False\n"); } else { printf("True\n"); } break; case 6: num = isfull(q); if (num == 0) { printf("False\n"); } else { printf("True\n"); } break; case 7: end = 0; break; } } return 0; }
/* check if queue q is empty */ int queue_is_empty(queue *q){ return ((front(q)==NULL) && (rear(q)==NULL)); }