-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Have a need to examine the contents of the circular buffer and build a list based on insert order.
Initially read your blog and the following snippet is based on your initial revision there.
public List<T> getAllOrdered() {
List<T> list = new Vector<T>(size);
for (int i = index.get() + 1; i < size; i++) {
if(buffer.get(i) != null)
list.add(buffer.get(i));
}
for (int i = 0; i < index.get() + 1; i++)
list.add(buffer.get(i));
return list;
}
The code might not be thread safe in that the buffer might get updated while I am building the list. Hoping I can download the code from github and use as a library with the above method included.
Regards
Suneet
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels