{"id":17878006,"url":"https://github.com/avitkauskas/mojo-datastructs","last_synced_at":"2025-03-22T05:31:38.835Z","repository":{"id":257975571,"uuid":"868399337","full_name":"avitkauskas/mojo-datastructs","owner":"avitkauskas","description":"Some data structures that are not yet implemented in the standard library of Mojo.","archived":false,"fork":false,"pushed_at":"2024-10-17T14:54:02.000Z","size":6391,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T12:22:42.312Z","etag":null,"topics":["deque","mojo"],"latest_commit_sha":null,"homepage":"","language":"Mojo","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avitkauskas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"publiccode":null,"codemeta":null}},"created_at":"2024-10-06T09:35:28.000Z","updated_at":"2024-10-17T14:54:06.000Z","dependencies_parsed_at":"2024-10-18T02:16:04.010Z","dependency_job_id":null,"html_url":"https://github.com/avitkauskas/mojo-datastructs","commit_stats":null,"previous_names":["avitkauskas/mojo-datastructs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitkauskas%2Fmojo-datastructs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitkauskas%2Fmojo-datastructs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitkauskas%2Fmojo-datastructs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avitkauskas%2Fmojo-datastructs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avitkauskas","download_url":"https://codeload.github.com/avitkauskas/mojo-datastructs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244912800,"owners_count":20530764,"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":["deque","mojo"],"created_at":"2024-10-28T12:00:40.801Z","updated_at":"2025-03-22T05:31:38.829Z","avatar_url":"https://github.com/avitkauskas.png","language":"Mojo","funding_links":[],"categories":["🗂️ Libraries\u003ca id='libraries'\u003e\u003c/a\u003e"],"sub_categories":["Data Structures"],"readme":"# Some missing data structures for Mojo\n\n\u003e As of the Mojo nightly build `mojo 2024.11.1705 (43b6e3df)`, this implementation of `Deque`\nis included in the Mojo standard library and is further maintained there by the Modular team and contributors.\nThis repository will not be updated with the latest changes from the official Mojo repository.\nPlease use `Deque` from the Mojo standard library:\n```mojo\nfrom collections import Deque\n```\n\n## Deque (Double-Ended Queue)\n\nThis implementation provides a double-ended queue (deque), built on a dynamically resizing circular buffer.\nIt supports efficient pushing and popping from both ends in O(1) time, as well as O(1) access to any element at any position in the deque.\n\nAs Mojo is designed to be a superset of Python, this Deque implementation supports the full Python `collections.deque` API,\nalong with additional methods and options for enhanced performance and flexibility.\n\n### Supported Python API\n\nThe following Python `deque` methods are all implemented:\\\n`append`, `appendleft`, `clear`, `count`, `extend`, `extendleft`, `index`,\\\n`insert`, `remove`, `pop`, `popleft`, `reverse`, `rotate`.\n\nDeque also supports equality comparisons and can be treated as a boolean value, where an empty deque evaluates to `False`,\nand a non-empty deque evaluates to `True`.\\\nMembership tests `if element in deque` and iteration `for element in deque` work as expected.\n\nIn general, the Deque should function just like the Python deque.\nIf you're unfamiliar with the Python implementation, refer to the Python documentation for more details:\\\n[Python Collections Documentation](https://docs.python.org/3/library/collections.html#collections.deque).\n\n### Additional Features\n\nIn addition to the Python API, Deque provides two convenience methods:\n- `peek()`: Returns the last element without removing it.\n- `peekleft()`: Returns the first element without removing it.\n\n### Constructor Options for Optimization\n\nBeyond Python’s `maxlen` argument, this Deque offers additional constructor options: `capacity`, `min_capacity`, and `shrink`.\nThese allow you to fine-tune the deque’s behavior for speed or memory usage based on your application’s needs.\n\nBy default, the deque allocates memory for 64 elements and adjusts its size automatically as needed.\nHowever, if you want to optimize performance and reduce buffer reallocations, these additional options can be helpful:\n\n- `capacity`: sets the initial size of the deque when created.\n- `min_capacity`: ensures the buffer will retain memory for at least this many elements,\\\neven if the deque's actual size drops below that number.\n- `shrink`: disables shrinking entirely when set to `shrink=False`.\\\nThis ensures that the buffer only grows as needed but never shrinks, optimizing for performance at the cost of memory usage.\n\nFor example, if you expect your deque to quickly grow to 10'000 elements but rarely drop below 5'000,\nyou can initialize it with `Deque(capacity=10000, min_capacity=5000)`. This will reduce expensive buffer reallocations and improve performance.\nAlternatively, if speed is the priority and memory usage is less of a concern, you can use `Deque(capacity=10000, shrink=False)`,\nwhich allocates memory for 10'000 elements upfront and prevents shrinking altogether, anticipating future growth.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitkauskas%2Fmojo-datastructs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favitkauskas%2Fmojo-datastructs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favitkauskas%2Fmojo-datastructs/lists"}