Home

enqueue

Enqueue is the operation of adding an element to the end of a queue data structure, where the order of elements is typically first in, first out (FIFO). The counterpart is dequeue, which removes and returns the element at the front of the queue.

In data structures, a queue supports enq at the rear and often deq at the front. Implementations

In software systems, enqueue is used for scheduling, buffering, and asynchronous processing. In messaging systems, an

Terminology varies: the operation may be called enqueue, enq, offer, or push in different languages or libraries.

include
linked
lists,
which
provide
O(1)
insertion
at
the
tail,
and
dynamic
arrays
or
circular
buffers,
which
can
offer
O(1)
amortized
time
but
may
require
resizing
or
wrap-around
logic.
Bounded
queues
have
a
fixed
capacity,
while
unbounded
queues
can
grow
as
needed.
Correct
handling
of
concurrency
is
important
in
multi-threaded
contexts
to
prevent
race
conditions
or
data
corruption.
enqueue
operation
places
a
message
on
a
queue
for
later
delivery
to
a
consumer.
Enqueued
messages
may
be
processed
by
one
or
more
workers,
possibly
with
delivery
guarantees
such
as
at-least-once,
exactly-once,
or
at-most-once,
depending
on
the
system.
Some
queues
support
prioritization
or
multiple
sub-queues.
It
is
distinct
from
push,
which
often
refers
to
stacks
in
some
contexts.
Enqueue
remains
a
core
concept
in
algorithms,
data
structures,
and
distributed
systems
for
managing
ordered,
buffered
work
or
messages.