java.lang.Iterable<E>
, java.util.Collection<E>
, java.util.Queue<E>
FileBackedByteQueue
, FileBackedIntQueue
, FileBackedLongQueue
, FileBackedShortQueue
, FileBackedStringQueue
public class FileBackedQueue<E>
extends java.util.AbstractQueue<E>
QueueSerializer
zu implementieren. Wichtig: nachdem die Queue nicht mehr gebraucht wird sollte clear()
aufgerufen werden um nicht mehr gebrauchten Speicher auf der Festplatte freizugeben.Constructor | Description |
---|---|
FileBackedQueue(int memoryCapacity,
long filesystemCapacity) |
Erstellt eine neue Queue, die durch ein Dateisystem unterstützt wird und so recht groß werden kann.
|
FileBackedQueue(int memoryCapacity,
long filesystemCapacity,
QueueSerializer<E> queueSerializer) |
Erstellt eine neue Queue, die durch ein Dateisystem unterstützt wird und so recht groß werden kann.
|
Modifier and Type | Method | Description |
---|---|---|
void |
clear() |
Removes all of the elements from this queue.
|
long |
getDiskCapacity() |
Gibt den maximal genutzen Festplattenplatz zurück, der von dieser Queue verwendet wird.
|
long |
getDiskUsed() |
Gibt den Festplattenplatz zurück, der von dieser Queue in Benutzung ist.
|
int |
getMemoryCapacity() |
Gibt die Kapazität des Caches in Bytes zurück, in dem die Objekte im Arbeitsspeicher gehalten werden.
|
int |
getMemoryUsed() |
Gibt den Speicher zurück, den die Objekte im Arbeitsspeicher verwenden.
|
java.util.Iterator<E> |
iterator() |
Returns an iterator over the elements contained in this collection.
|
boolean |
offer(E e) |
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
|
E |
peek() |
Retrieves, but does not remove, the head of this queue, or returns
null if this queue is empty. |
E |
poll() |
Retrieves and removes the head of this queue, or returns
null if this queue is empty. |
int |
size() |
|
java.lang.String |
toString() |
contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
public FileBackedQueue(int memoryCapacity, long filesystemCapacity, QueueSerializer<E> queueSerializer)
memoryCapacity
- Wie viel Speicher in Bytes maximal im Arbeitsspeicher gehalten werden sollen. Es handelt sich um einen Richtwert, der geringfügig
(um die Größe eines Elements) überschritten werden kann. Berücksichtigt wird hier nicht der tatsächliche Arbeitsspeicherverbrauch,
sondern die Größe, die das Element verbrauchen würde, falls es serialisiert werden würde.filesystemCapacity
- Wie viel Speicher in Bytes maximal im Dateisystem gehalten werden sollen. Es handelt sich um einen Richtwert, der geringfügig (um
maximal die Größe eines Elements minus 1 Byte) überschritten werden kann.queueSerializer
- Klasse, die das Deserialisieren von Objekten übernimmt.public FileBackedQueue(int memoryCapacity, long filesystemCapacity)
memoryCapacity
- Wie viel Speicher in Bytes maximal im Arbeitsspeicher gehalten werden sollen.filesystemCapacity
- Wie viel Speicher in Bytes maximal im Dateisystem gehalten werden sollen. Es handelt sich um einen Richtwert, der geringfügig (um
maximal die Größe eines Elements) überschritten werden kann.public java.util.Iterator<E> iterator()
It is imperative that the user manually synchronize on the returned collection when iterating over it:
Collection c = myFileBackedQueue; ... synchronized(c) { Iterator i = c.iterator(); // Must be in the synchronized block while (i.hasNext()) foo(i.next()); }Failure to follow this advice may result in non-deterministic behavior.
public int size()
public boolean offer(E e)
AbstractQueue.add(E)
, which can fail to insert an element only by throwing an exception.e
- the element to addtrue
if the element was added to this queue, else false
java.lang.ClassCastException
- if the class of the specified element prevents it from being added to this queuejava.lang.NullPointerException
- if the specified element is null and this queue does not permit null elementsjava.lang.IllegalArgumentException
- if some property of this element prevents it from being added to this queuepublic E poll()
null
if this queue is empty.null
if this queue is emptypublic E peek()
null
if this queue is empty.null
if this queue is emptypublic int getMemoryUsed()
public int getMemoryCapacity()
public long getDiskUsed()
public long getDiskCapacity()
public void clear()
public java.lang.String toString()
toString
in class java.util.AbstractCollection<E>