Warning: session_start(): open(/var/lib/php/sessions/sess_c6j263eco3p4dcauga9fmsjipn, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass SynchronizedCircularFifoBuffer is Iterable, IntSize {
int capacity;
long base;
ArrayDeque coreStorage; // Unsynched core list
Cl storage; // synched coreStorage
*(int capacity) {
this.capacity = capacity;
coreStorage = new ArrayDeque(capacity);
storage = synchronizedCollection(coreStorage);
}
/**
* Adds the given element to the buffer. If the buffer is full, the least recently added element is discarded so
* that a new element can be inserted.
*/
public void add(E e) {
synchronized(storage) {
if (isFull()) remove();
coreStorage.addLast(e);
}
}
/**
* Removes and returns the least recently inserted element from this buffer.
*/
public E remove() {
synchronized(storage) {
++base;
return coreStorage.removeFirst();
}
}
/**
* Returns true iff the buffers remaining capacity is 0.
*/
public boolean isFull() {
return storage.size() == capacity;
}
/**
* Returns true iff the buffers size is 0.
*/
public boolean isEmpty() {
return storage.isEmpty();
}
/**
* Returns the number of elements in the buffer.
*/
public int size() {
return storage.size();
}
public Object[] toArray() {
return storage.toArray();
}
public T[] toArray(T[] a) {
return storage.toArray(a);
}
public List asList() {
return new ArrayList(storage);
}
public Cl ArrayDeque getBackingStore() {
ret storage;
}
public Iterator iterator() {
return storage.iterator();
}
// how many elements were discarded
synchronized long getBase() { ret base; }
synchronized int getCapacity() { ret capacity; }
}