Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

std::queue

Explanation

FIFO (First In, First Out). Uses std::deque internally.

See std::queue.

Time complexity:

OperationComplexity
push()O(1)
pop()O(1)
empty(), size()O(1)

Code

#include <print>
#include <queue>

int main() {
  std::queue<uint64_t> workQueue;

  workQueue.push(0x1000);
  workQueue.push(0x2000);
  workQueue.push(0x3000);

  while (!workQueue.empty()) {
    std::println("Process: {:#x}", workQueue.front());
    workQueue.pop();
  }

  return 0;
}

View on GitHub.

Output

$ ./src/data-structures/build/std-queue
Process: 0x1000
Process: 0x2000
Process: 0x3000