| | | | | |

Queue ADT

Collection: elements of some proper type T
Operations:
  • void push (T t)
  • void pop ()
  • T front ()
  • bool empty ()
  • unsigned int size ()
  • (plus constructor and destructor)
Axioms: (for any Queue Q)
  1. Q.size(), Q.empty(), Q.push(t) are always defined
  2. Q.pop() and Q.front() are defined iff Q.empty() is false
  3. Q.empty(), Q.size(), Q.front() do not change Q
  4. Q.empty() is true iff 0 = Q.size()
  5. Suppose n = Q.size() and the next element pushed onto Q is t;
    then, after n elements have been popped from Q, t = Q.front()
  6. Q.push(t) increases Q.size() by 1
  7. Q.pop() decreases Q.size() by 1
  8. If t = Q.front() then Q.pop() removes t from Q

| | Top of Page | 5. Abstract Data Types: Stacks and Queues - 6 of 22