Queue data structure

  • FIFO (First In First Out) data structure.
  • Basic operations
    • Insert – Offer
    • Remove – Poll
    • Examine – Peek
  • Variants
    • Priority queue – Poll gives the element based on the priority.
    • Blocking queue – Blocks the request for offer until the space available. Same with poll – blocks until queue has an element to return.
    • Deque – Double Ended Queue. Supports insertion and removal from front and the rear ends. Hence supports both stack and queue.
    • Transfer Queue – Variant of blocking queue in which producer blocks until the consumer give an acknowledgement on the receipt.
    • Delay queue – Variant of blocking queue in which an inserted element can only be available for poll (removal) once the set delay is expired.
  • Java JDK queue
  • Applications
    • Serving n items sequentially need a queue.
    • If the producer and consumer works at different speeds, then there needs a queue (messaging queues)

Leave a Reply

Your email address will not be published. Required fields are marked *