Transpiled version (70L) is out of date.
persistable sclass SynchronizedCircularBuffer<A> { A[] buffer; long base; // elements dropped due to overcapacity int size; // elements actually contained *(int capacity) { buffer = (A[]) new O[capacity]; } synchronized void add(A a) { if (size == buffer.length) { --size; ++base; } buffer[(int) ((base+size) % buffer.length)] = a; ++size; } synchronized A get(long pos) { if (pos < base || pos >= base+size) null; ret buffer[(int) (pos % buffer.length)]; } synchronized int size() { ret size; } synchronized int capacity() { ret buffer.length; } synchronized bool isFull() { ret size() == capacity(); } synchronized long getBase() { ret base; } }
Began life as a copy of #1026626
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1036465 |
Snippet name: | SynchronizedCircularBuffer - duplicate of SimpleCircularBuffer |
Eternal ID of this version: | #1036465/5 |
Text MD5: | 19c62f0bdc3a2be929c53801af2cbe85 |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-12-16 05:15:41 |
Source code size: | 797 bytes / 39 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 148 / 203 |
Version history: | 4 change(s) |
Referenced in: | -