https://github.com/bsdelf/ring.js
A circular queue use indexed collections as its backend.
https://github.com/bsdelf/ring.js
Last synced: 5 months ago
JSON representation
A circular queue use indexed collections as its backend.
- Host: GitHub
- URL: https://github.com/bsdelf/ring.js
- Owner: bsdelf
- License: mit
- Created: 2017-07-19T08:52:15.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-04T09:14:47.000Z (over 8 years ago)
- Last Synced: 2025-02-13T05:44:53.410Z (10 months ago)
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ring.js
A circular queue use indexed collections as its backend.
## Syntax
```javascript
new Ring(capacity)
new Ring(capacity, Uint8Array)
```
## Properties
- `Ring.prototype.capacity`
Reflects the capacity of the ring.
- `Ring.prototype.used`
Reflects the number of used elements.
- `Ring.prototype.free`
Reflects the number of free elements.
- `Ring.prototype.empty`
Reflects whether the ring is empty.
- `Ring.prototype.full`
Reflects whether the ring is full.
## Methods
- `Ring.prototype.pop()`
Removes the last element from a ring and returns that element.
- `Ring.prototype.push()`
Adds one element to the end of a ring.
- `Ring.prototype.shift()`
Removes the first element from a ring and returns that element.
- `Ring.prototype.unshift()`
Adds one element to the front of a ring.
- `Ring.prototype.clear()`
Clears all elements of a ring.
- `Ring.prototype.toArray()`
Returns a newly created array with all elements of a ring.
- `Ring.prototype.lowerBound(first, last, value[, comp])`
Returns the first index at which a given element in the range [first, last) that is not less than (i.e. greater or equal to) value, or last if no such element is found.