CS 225 Lecture Notes - Lecture 18: Time Complexity, Iterator, Linked List
Document Summary
Queue array based implementation: template class queue { public: Queue(); ~queue(); // etc. bool empty() const; void enqueue(const sit & e); // entry is d// m is exit exit rig^ht here now. // we could reposition entry to the beggining of the array instead, this way we use unused spaces. // the reason exit is in the middle of the array is to keep track of what needs to be kept and removed, this way the next thing to remove is the exit, m. // this method will wrap around the array. // everytime you increment the array indicies is done mod array capacity. , to make sure it"s within the range of the array or to increment properly, good thing to check when we also double size enqueue(m); enqueue(o); enqueue(y); enqueue(i); Cs 225 - lecture page 1 enqueue(o); enqueue(n); enqeueue(d); enqueue(a); enqueue(i); enqueue(s); dequeue(); enqeueue(h); enqeueue(a);