queue.tex 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. \chapter{TQueue}
  2. Implements queue.
  3. Usage example:
  4. \lstinputlisting[language=Pascal]{queueexample.pp}
  5. Memory complexity:
  6. Since underlaying structure is TDeque, memory complexity is same.
  7. Members list:
  8. \begin{longtable}{|m{10cm}|m{5cm}|}
  9. \hline
  10. Method & Complexity guarantees \\ \hline
  11. \multicolumn{2}{|m{15cm}|}{Description} \\ \hline\hline
  12. \verb!Create! & O(1) \\ \hline
  13. \multicolumn{2}{|m{15cm}|}{Constructor. Creates empty queue.} \\ \hline\hline
  14. \verb!function Size(): SizeUInt! & O(1) \\ \hline
  15. \multicolumn{2}{|m{15cm}|}{Returns number of elements in queue.} \\\hline\hline
  16. \verb!procedure Push(value: T)! & Amortized
  17. O(1), some operations might take O(N) time, when array needs to be reallocated, but sequence of N
  18. operations takes O(N) time \\ \hline
  19. \multicolumn{2}{|m{15cm}|}{Inserts element at the back of queue.} \\\hline\hline
  20. \verb!procedure Pop()! & O(1) \\\hline
  21. \multicolumn{2}{|m{15cm}|}{Removes element from the beginning of queue. If queue is empty does nothing.} \\\hline\hline
  22. \verb!function IsEmpty(): boolean! & O(1) \\ \hline
  23. \multicolumn{2}{|m{15cm}|}{Returns true when queue is empty.} \\\hline\hline
  24. \verb!function Front: T! & O(1) \\\hline
  25. \multicolumn{2}{|m{15cm}|}{Returns the first element from queue.} \\\hline
  26. \end{longtable}