|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SequenceCircler
public final class SequenceCircler
Circular indexing for a fixed-length sequence.
Thread safe, except where marked.
Constructor Summary | |
---|---|
SequenceCircler(int s)
Creates a SequenceCircler. |
Method Summary | |
---|---|
int |
getCursor()
Returns the index of the cursor. |
int |
indexOf(int offset)
Returns the circular (wrapped) index of an offset from the cursor. |
void |
setCursor(int c)
Sets the index of the cursor. |
int |
size()
Returns the size of the sequence. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SequenceCircler(int s)
s
- size per size()Method Detail |
---|
public int getCursor()
public void setCursor(int c)
Thread-safe iff setters sync (and getters touch-sync) on SequenceCircler.this for cross-thread visibility/ordering of writes.
c
- new index of the cursor
ArrayIndexOutOfBoundsException
- if c < 0 or c >= size()public int indexOf(int offset)
offset
- (positive or negative) from the cursor
ArrayIndexOutOfBoundsException
- if |offset| > size(),
which would wrap past the cursorpublic int size()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |