Package for an indexable circular array data structure.
Project description
Python Circular Array Implementation
Best used as either a standalone improved Python list or in the implementing of other Python data structures.
- Python module implementing an indexable, double sided queue
- See grscheller.circular-array project on PyPI
- See Detailed API documentation on GH-Pages
- See Source code on GitHub
Overview
The CircularArray class implements an auto-resizing, indexable, double sided queue data structure. O(1) indexing and O(1) pushes and pops either end. Useful if used directly as an improved version of a Python List and in the implementation of other data structures in a "has-a" relationship.
Usage
from grscheller.circular_array.ca import CA
ca = CA(1, 2, 3)
assert ca.popF() == 1
assert ca.popR() == 3
ca.pushR(42, 0)
ca.pushF(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.popFT(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.popFD(42) == 1
assert ca.popRD(42) == 3
assert ca.popFD(42) == 2
assert ca.popRD(42) == 42
assert ca.popFD(42) == 42
assert len(ca) == 0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for grscheller_circular_array-3.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c1560fbec9ba60a1a99bf1346392fb4838f0b05b17972a553806473db9e2b32 |
|
MD5 | 816868ff1fb7e471b3a3b8fdb7218ea4 |
|
BLAKE2b-256 | 5aa228c5212b6912f244c8f5a41e925b1c21f3f5c106335554a4ae02455026bb |
Close
Hashes for grscheller_circular_array-3.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 551820de356937e55abfbdcde80d97c2ef6b98f7b406caa9bdd67c73c0299b8c |
|
MD5 | 3e08f62c7fb48ff5c59a3be2a035d0e1 |
|
BLAKE2b-256 | 7039e1a1293f81c8c7c690081084023838edc5771efd290b6f64e9a19de82301 |