答案:是个5个抽屉的fifo pipe。仅实现了存取方法,可以做相应修改以满足不同的要求。
public class Pipe{
String[] strContent = {"","","","",""} ;int[] intIndex = {1,2,3,4,5};
public int setStrContent(String strLine) {
for(int i=0;i<5;i++)
{
if(intIndex[i] == 0)
{
strContent[i] = strLine;
intIndex[i] = 5;
return 0;
}
}
return -1;
}public String getStrContent() {
for (int i = 0; i < 5; i++) {
intIndex[i]--;
if (intIndex[i] == 0) {
return strContent[i];
}
}
return "";
}}