{"id":23034736,"url":"https://github.com/ibnaleem/queue","last_synced_at":"2025-04-02T22:21:51.816Z","repository":{"id":223326882,"uuid":"759939860","full_name":"ibnaleem/queue","owner":"ibnaleem","description":"Queue data structure in Python","archived":false,"fork":false,"pushed_at":"2024-02-24T00:16:09.000Z","size":14,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-08T12:46:18.125Z","etag":null,"topics":["arrays","data-structures","data-visualization","lists","queue","queueing","queues"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ibnaleem.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-02-19T16:17:16.000Z","updated_at":"2024-02-19T16:56:41.000Z","dependencies_parsed_at":"2024-02-24T01:25:39.638Z","dependency_job_id":null,"html_url":"https://github.com/ibnaleem/queue","commit_stats":null,"previous_names":["ibnaleem/queue"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibnaleem%2Fqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibnaleem%2Fqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibnaleem%2Fqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ibnaleem%2Fqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ibnaleem","download_url":"https://codeload.github.com/ibnaleem/queue/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246900435,"owners_count":20852053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arrays","data-structures","data-visualization","lists","queue","queueing","queues"],"created_at":"2024-12-15T16:35:28.670Z","updated_at":"2025-04-02T22:21:51.797Z","avatar_url":"https://github.com/ibnaleem.png","language":"Python","readme":"# Queue\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"https://media.geeksforgeeks.org/wp-content/cdn-uploads/20230726165642/Queue-Data-structure1.png\" width=\"50%\" height=\"50%\"\u003e\n  \u003ch6\u003e\u003ci\u003e\u003ca href=\"https://www.geeksforgeeks.org/queue-data-structure/\"\u003eQueue Data Structure, GeeksForGeeks.org\u003c/a\u003e\u003c/i\u003e\u003c/h6\u003e\n\u003c/div\u003e\n\nA Queue is a linear data structure characterised by its first-in-first-out (FIFO) behaviour. Queues `pop` (remove, `'dequeue'`) the `head` (front, first element) of the Queue (i.e `1` is `'dequeued'` from `[1,2,3,4,5]`) and `append` (add, put, `'enqueue'`) an element at the `tail` (back, rear, last element) of the Queue. Queues are fixed sized, meaning an object cannot be enqueued if the Queue is full.\n### Example\n```python\nq = Queue([1,2,3,4,5])\nprint(q)\n```\n```\n[1,2,3,4,5]\nSize: 6 (one more than the length of the Queue)\n```\n```python\nq.enqueue(6)\nprint(q)\n```\n```\n[1,2,3,4,5,6]\n```\n```python\nq.dequeue() # no args since it will always remove the head of the Queue\nprint(q)\n```\n```\n[2,3,4,5,6]\nRemoved: 1 (previous head)\nNew head: 2\n```\n```python\nq.enqueue(7)\n```\n```\n[2,3,4,5,6,7]\n```\n```python\nq.enqueue(8)\n```\n```\nraise QueueFullError(\"Cannot enqueue at full size: 6\")\n```\n## Classes, Attributes, Methods and Exceptions\n### Classes\n- `Queue(items: object = None, size: int = None)` - Optional parameters: `items` (the items in the queue) and `size` (the size allocated for the queue)\n### Attributes\n- `items` - the queue itself, more specifically its items, constructed as a list\n- `size` - the size of the queue\n- `head` - the first element of the queue, i.e `self.items[0]`\n- `tail` - the last element of the queue, i.e `self.items[-1]`\n### Methods\n- `enqueue(item: object)` - appends an `object` to the end of the queue; extends the queue if `object` is of type `list`\n-  `dequeue()` - removes the `head` of the queue (`self.items.pop(0)`)\n-  `peek()` - equivalent to `head` attribute\n-  `clear()` - empties the queue\n-  `merge(queue: 'Queue')` - merges two queues together via `enqueue()` method\n-  `frequency(item: object)` - returns the amount of times (frequency) an item is present in a queue\n-  `copy()` - creates a copy of current queue and returns it\n-  `is_full()` - returns a `True` if queue is full\n-  `is_empty()` - returns `True` if queue is empty\n-  `available_size()` - subtracts the length of the queue by the `size` attribute to calculate the available size remaining in the queue\n-  `sort()` - sorts the queue in ascending order \n### Exceptions:\n- `QueueFullError()` - Raised when attempting to enqueue a full Queue, exceeding its fixed size\n- `QueueEmptyError()` - Raised when attempting to dequeue an empty Queue\n- `QueueError()` - Raised when ran into esoteric errors, such as trying to enqueue 2D arrays\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibnaleem%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fibnaleem%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fibnaleem%2Fqueue/lists"}