public class MemoryLimitedList<T> extends Object implements AppendList<T>
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.
If current size is over limited size, a GuaguaRuntimeException is added when #add(Object).
AppendList.State| Constructor and Description |
|---|
MemoryLimitedList(List<T> delegationList)
Constructor with delegation list
|
MemoryLimitedList(long maxSize,
List<T> delegationList)
Constructor with max bytes size limit and delegation list.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
append(T t)
Append object to this list
|
void |
clear()
Clear all elements.
|
T |
get(int index)
Retrieve record given index.
|
Iterator<T> |
iterator() |
int |
size()
Return size of this list.
|
void |
switchState()
After appending, switch state from WRITE to READ to allow iterating.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic MemoryLimitedList(long maxSize,
List<T> delegationList)
public boolean append(T t)
AppendListappend in interface AppendList<T>t - the object to appendpublic T get(int index)
MemoryLimitedList.index - the index of record to be returnedpublic void switchState()
AppendListswitchState in interface AppendList<T>public int size()
AppendListsize in interface AppendList<T>public void clear()
AppendListclear in interface AppendList<T>Copyright © 2019. All Rights Reserved.