public class DiskList<T extends Serializable> extends Object implements AppendList<T>
No size limit for this list but user should make sure valid fileName when constructing.
Only two stages support in such kind of list. The first one is WRITE, the next is read. So far random WRITE and READ are not supported in this list.
WARNING: close() should be called at last if use such List.
AppendList.State| Constructor and Description |
|---|
DiskList(String fileName)
Constructor with file name in current working dir.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
append(T t)
Append object to this list
|
void |
clear()
Clear all elements.
|
void |
close()
This method should be called at the end of
DiskList usage to release file descriptors. |
ObjectSerializer<T> |
getSerializer() |
Iterator<T> |
iterator() |
void |
reOpen()
Re-open stream for iterators.
|
void |
setSerializer(ObjectSerializer<T> serializer) |
int |
size()
Return size of this list.
|
void |
switchState()
Switch state from WRITE to READ
|
public DiskList(String fileName)
public void switchState()
switchState in interface AppendList<T extends Serializable>public void reOpen()
public boolean append(T t)
AppendListappend in interface AppendList<T extends Serializable>t - the object to appendpublic void close()
DiskList usage to release file descriptors.public Iterator<T> iterator()
iterator in interface Iterable<T extends Serializable>public ObjectSerializer<T> getSerializer()
public void setSerializer(ObjectSerializer<T> serializer)
serializer - the serializer to setpublic int size()
AppendListsize in interface AppendList<T extends Serializable>public void clear()
AppendListclear in interface AppendList<T extends Serializable>Copyright © 2015. All Rights Reserved.