{"record":{"id":"b13eaaf17590a9f5","repo":"TheAlgorithms/Python","slug":"full-queue","errorCode":null,"errorMessage":"Full Queue","messagePattern":"Full Queue","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"data_structures/queues/circular_queue_linked_list.py","lineNumber":148,"sourceCode":"            return None\n        if self.front == self.rear:\n            data = self.front.data\n            self.front.data = None\n            return data\n\n        old_front = self.front\n        self.front = old_front.next\n        data = old_front.data\n        old_front.data = None\n        return data\n\n    def check_can_perform_operation(self) -> None:\n        if self.is_empty():\n            raise Exception(\"Empty Queue\")\n\n    def check_is_full(self) -> None:\n        if self.rear and self.rear.next == self.front:\n            raise Exception(\"Full Queue\")\n\n\nclass Node:\n    def __init__(self) -> None:\n        self.data: Any | None = None\n        self.next: Node | None = None\n        self.prev: Node | None = None\n\n\nif __name__ == \"__main__\":\n    import doctest\n\n    doctest.testmod()\n","sourceCodeStart":130,"sourceCodeEnd":162,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/data_structures/queues/circular_queue_linked_list.py#L130-L162","documentation":"CircularQueueLinkedList.check_is_full raises a generic Exception('Full Queue') when rear.next == front — the pre-allocated ring of Nodes is fully occupied and enqueue would overwrite the oldest item. enqueue() calls it before advancing rear, so the raised call leaves the queue state unchanged.","triggerScenarios":"Enqueueing more items than the initial_capacity passed to the constructor (default 6) without dequeuing; e.g. capacity 2 with a third enqueue, as in the class doctest.","commonSituations":"Throughput mismatch between producer and consumer on a fixed-size ring; constructor capacity copied from an old spec while payload volume grew; assuming the queue grows dynamically like list-based queues.","solutions":["Track occupancy on the caller side or compare against initial_capacity before enqueueing.","Dequeue one item before each enqueue once full (single-slot rotation).","Construct the queue with capacity >= maximum concurrent items, e.g. len(burst)+1 headroom."],"exampleFix":"# before\ncq.enqueue(item)  # Exception: Full Queue\n# after\nif cq.rear and cq.rear.next == cq.front:\n    cq.dequeue()  # make room\ncq.enqueue(item)","handlingStrategy":"validation","validationCode":"def enqueue(cq, item):\n    if cq.rear and cq.rear.next == cq.front:\n        cq.dequeue()  # recycle the oldest slot\n    cq.enqueue(item)","typeGuard":null,"tryCatchPattern":"try:\n    cq.enqueue(item)\nexcept Exception as e:\n    if 'Full Queue' not in str(e):\n        raise\n    cq.dequeue()\n    cq.enqueue(item)","preventionTips":["Track enqueued-minus-dequeued count against initial_capacity (default 6).","Construct with capacity sized to peak occupancy plus headroom.","enqueue is not idempotent on failure — the check fires before state changes."],"tags":["queue","overflow","circular-buffer","capacity"],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}