Package com.gengoai.collection.disk
Class DiskQueue<E>
- java.lang.Object
-
- com.gengoai.collection.disk.DiskQueue<E>
-
- Type Parameters:
E
- the element type parameter
- All Implemented Interfaces:
Serializable
,AutoCloseable
,Iterable<E>
,Collection<E>
,Queue<E>
public class DiskQueue<E> extends Object implements Queue<E>, Serializable, AutoCloseable
A Queue implementation that stores its data in a file. DiskQueue are monitored to ensure that their file handle is properly closed if the it is no longer in use. However, one can use the
commit
andclose
methods to explicitly commit changes and close the queue.DiskQueue are created using a builder in the following way:
var map = DiskQueue.builder() .file(Resources.from("/data/map.db") .namespace("people") .compressed(true) .build();
Once an DiskQueue instance is constructed it acts like regular Java Queue.
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E e)
boolean
addAll(Collection<? extends E> collection)
void
clear()
void
close()
void
commit()
Commit.boolean
contains(Object o)
boolean
containsAll(Collection<?> collection)
E
element()
boolean
isEmpty()
Iterator<E>
iterator()
boolean
offer(E e)
E
peek()
E
poll()
E
remove()
boolean
remove(Object o)
boolean
removeAll(Collection<?> collection)
boolean
retainAll(Collection<?> collection)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] ts)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Method Detail
-
add
public boolean add(E e)
-
addAll
public boolean addAll(Collection<? extends E> collection)
- Specified by:
addAll
in interfaceCollection<E>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<E>
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
commit
public void commit()
Commit.
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
-
containsAll
public boolean containsAll(Collection<?> collection)
- Specified by:
containsAll
in interfaceCollection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
-
removeAll
public boolean removeAll(Collection<?> collection)
- Specified by:
removeAll
in interfaceCollection<E>
-
retainAll
public boolean retainAll(Collection<?> collection)
- Specified by:
retainAll
in interfaceCollection<E>
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] ts)
- Specified by:
toArray
in interfaceCollection<E>
-
-