ml.shifu.guagua.util
接口 AppendList<T>

所有超级接口:
Iterable<T>
所有已知实现类:
BytableDiskList, BytableMemoryDiskList, DiskList, MemoryDiskList, MemoryLimitedList

public interface AppendList<T>
extends Iterable<T>

Appendable list interface definition.

Two states are in this list. State AppendList.State.WRITE when instance created, then element can be append to tail. After all elements are appended, switch state to AppendList.State.READ. When state is AppendList.State.READ, data cannot be appended, only can be iterative.

Only support appending element to tail and iterative reading.

Such code as an example:

 AppendList<Data> dataList = new MemoryDiskList<Data>(60L, "c.txt");
 dataList.append(new Data(1, 1));
 dataList.append(new Data(2, 2));
 dataList.append(new Data(3, 3));
 dataList.append(new Data(4, 4));
 
 dataList.switchState();
 
 for(Data d: dataList) {
     System.out.println(d);
 }
 

作者:
Zhang David (pengzhang@paypal.com)

嵌套类摘要
static class AppendList.State
          Inner state definition.
 
方法摘要
 boolean append(T t)
          Append object to this list
 void clear()
          Clear all elements.
 long size()
          Return size of this list.
 void switchState()
          After appending, switch state from WRITE to READ to allow iterating.
 
从接口 java.lang.Iterable 继承的方法
iterator
 

方法详细信息

append

boolean append(T t)
Append object to this list

参数:
t - the object to append
返回:
whether appending object successful
抛出:
IllegalStateException - if not in WRITE state.

switchState

void switchState()
After appending, switch state from WRITE to READ to allow iterating.


size

long size()
Return size of this list.


clear

void clear()
Clear all elements.



Copyright © 2015. All Rights Reserved.