dtools.circular-array


Namedtools.circular-array JSON
Version 3.9.1 PyPI version JSON
download
home_pageNone
Summary### Circular Array
upload_time2025-02-17 02:17:00
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseNone
keywords circular array circle array ca double ended queue dequeue dqueue pop push popl popr pushl pushr indexable auto-resizing auto resizing resizing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Developer Tools - Circular Array Implementation

Python module implementing a full featured, indexable,
double sided, auto-resizing queue data structure.

* **Repositories**
  * [dtools.circular-array][1] project on *PyPI*
  * [Source code][2] on *GitHub*
* **Detailed documentation**
  * [Detailed API documentation][3] on *GH-Pages*

This project is part of the
[Developer Tools for Python][4] **dtools.** namespace project.

### Overview

Useful if used directly as an improved version of a Python List or in
a "has-a" relationship when implementing other data structures.

* O(1) pushes and pops either end.
* O(1) indexing
* fully supports slicing
* iterates over copies of the data allowing ca to mutate

### Usage

```python
from dtools.circular_array.ca import CA

ca = CA(1, 2, 3)
assert ca.popL() == 1
assert ca.popR() == 3
ca.pushR(42, 0)
ca.pushL(0, 1)
assert repr(ca) == 'CA(1, 0, 2, 42, 0)'
assert str(ca) == '(|1, 0, 2, 42, 0|)'

ca = CA(*range(1,11))
assert repr(ca) == 'CA(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)'
assert str(ca) == '(|1, 2, 3, 4, 5, 6, 7, 8, 9, 10|)'
assert len(ca) == 10
tup3 = ca.popLT(3)
tup4 = ca.popRT(4)
assert tup3 == (1, 2, 3)
assert tup4 == (10, 9, 8, 7)

assert ca == CA(4, 5, 6)
four, *rest = ca.popFT(1000)
assert four == 4
assert rest == [5, 6]
assert len(ca) == 0

ca = CA(1, 2, 3)
assert ca.popLD(42) == 1
assert ca.popRD(42) == 3
assert ca.popLD(42) == 2
assert ca.popRD(42) == 42
assert ca.popLD(42) == 42
assert len(ca) == 0
```

---

[1]: https://pypi.org/project/dtools.circular-array
[2]: https://github.com/grscheller/dtools-circular-array
[3]: https://grscheller.github.io/dtools-docs/circular-array
[4]: https://github.com/grscheller/dtools-docs


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "dtools.circular-array",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "circular array, circle array, CA, double ended queue, dequeue, dqueue, pop, push, popL, popR, pushL, pushR, indexable, auto-resizing, auto resizing, resizing",
    "author": null,
    "author_email": "\"Geoffrey R. Scheller\" <geoffrey@scheller.com>",
    "download_url": "https://files.pythonhosted.org/packages/82/cc/c38bd3eb1e0a4db518e0ebb87186515a31ec078e73fb2d40cc5b1e1af9c1/dtools_circular_array-3.9.1.tar.gz",
    "platform": null,
    "description": "# Developer Tools - Circular Array Implementation\n\nPython module implementing a full featured, indexable,\ndouble sided, auto-resizing queue data structure.\n\n* **Repositories**\n  * [dtools.circular-array][1] project on *PyPI*\n  * [Source code][2] on *GitHub*\n* **Detailed documentation**\n  * [Detailed API documentation][3] on *GH-Pages*\n\nThis project is part of the\n[Developer Tools for Python][4] **dtools.** namespace project.\n\n### Overview\n\nUseful if used directly as an improved version of a Python List or in\na \"has-a\" relationship when implementing other data structures.\n\n* O(1) pushes and pops either end.\n* O(1) indexing\n* fully supports slicing\n* iterates over copies of the data allowing ca to mutate\n\n### Usage\n\n```python\nfrom dtools.circular_array.ca import CA\n\nca = CA(1, 2, 3)\nassert ca.popL() == 1\nassert ca.popR() == 3\nca.pushR(42, 0)\nca.pushL(0, 1)\nassert repr(ca) == 'CA(1, 0, 2, 42, 0)'\nassert str(ca) == '(|1, 0, 2, 42, 0|)'\n\nca = CA(*range(1,11))\nassert repr(ca) == 'CA(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)'\nassert str(ca) == '(|1, 2, 3, 4, 5, 6, 7, 8, 9, 10|)'\nassert len(ca) == 10\ntup3 = ca.popLT(3)\ntup4 = ca.popRT(4)\nassert tup3 == (1, 2, 3)\nassert tup4 == (10, 9, 8, 7)\n\nassert ca == CA(4, 5, 6)\nfour, *rest = ca.popFT(1000)\nassert four == 4\nassert rest == [5, 6]\nassert len(ca) == 0\n\nca = CA(1, 2, 3)\nassert ca.popLD(42) == 1\nassert ca.popRD(42) == 3\nassert ca.popLD(42) == 2\nassert ca.popRD(42) == 42\nassert ca.popLD(42) == 42\nassert len(ca) == 0\n```\n\n---\n\n[1]: https://pypi.org/project/dtools.circular-array\n[2]: https://github.com/grscheller/dtools-circular-array\n[3]: https://grscheller.github.io/dtools-docs/circular-array\n[4]: https://github.com/grscheller/dtools-docs\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "### Circular Array",
    "version": "3.9.1",
    "project_urls": {
        "Changelog": "https://github.com/grscheller/dtools-circular-array/blob/main/CHANGELOG.md",
        "Documentation": "https://grscheller.github.io/dtools-docs/circular-array",
        "Source": "https://github.com/grscheller/dtools-circular-array"
    },
    "split_keywords": [
        "circular array",
        " circle array",
        " ca",
        " double ended queue",
        " dequeue",
        " dqueue",
        " pop",
        " push",
        " popl",
        " popr",
        " pushl",
        " pushr",
        " indexable",
        " auto-resizing",
        " auto resizing",
        " resizing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "d47c4f9c26c0f52484738ba4efbaedfe3ddcd8ca3ef932e8fd727396a5ba4b55",
                "md5": "9c5e99c03793d4fe072ff0739ae54f1b",
                "sha256": "caaabe1025884a35aaf485379bd55fec96d71a78955f673de2235085c24935b0"
            },
            "downloads": -1,
            "filename": "dtools_circular_array-3.9.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c5e99c03793d4fe072ff0739ae54f1b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 10632,
            "upload_time": "2025-02-17T02:16:57",
            "upload_time_iso_8601": "2025-02-17T02:16:57.637232Z",
            "url": "https://files.pythonhosted.org/packages/d4/7c/4f9c26c0f52484738ba4efbaedfe3ddcd8ca3ef932e8fd727396a5ba4b55/dtools_circular_array-3.9.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "82ccc38bd3eb1e0a4db518e0ebb87186515a31ec078e73fb2d40cc5b1e1af9c1",
                "md5": "d45c92a947911ce722745d02f8a3af18",
                "sha256": "6b930261851e5878b0bbcf631025e056564bf1758df1575827463c1825e6d6ff"
            },
            "downloads": -1,
            "filename": "dtools_circular_array-3.9.1.tar.gz",
            "has_sig": false,
            "md5_digest": "d45c92a947911ce722745d02f8a3af18",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 15720,
            "upload_time": "2025-02-17T02:17:00",
            "upload_time_iso_8601": "2025-02-17T02:17:00.471441Z",
            "url": "https://files.pythonhosted.org/packages/82/cc/c38bd3eb1e0a4db518e0ebb87186515a31ec078e73fb2d40cc5b1e1af9c1/dtools_circular_array-3.9.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-02-17 02:17:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "grscheller",
    "github_project": "dtools-circular-array",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dtools.circular-array"
}
        
Elapsed time: 1.67593s