本文整理汇总了Java中org.apache.commons.collections.Buffer类的典型用法代码示例。如果您正苦于以下问题:Java Buffer类的具体用法?Java Buffer怎么用?Java Buffer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Buffer类属于org.apache.commons.collections包,在下文中一共展示了Buffer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
StringBuffer sb = new StringBuffer();
Buffer nl = NotificationList.getInstance().getNotifications();
Iterator<String> it = nl.iterator();
while (it.hasNext()) {
String notification = (String) it.next();
sb.append(notification);
}
nl.clear();
PrintWriter out = response.getWriter();
out.println(sb.toString());
}
示例2: main
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
public static void main(String[] args) {
Driver driver = new Driver();
Driver.DataRate imuFreq = Driver.DataRate.FREQ_476_HZ;
driver.setAccelerometerScale(Driver.AccelerometerScale.SCALE_PLUS_MINUS_2G);
driver.setDatarate(imuFreq);
driver.setUseFifoBuffer(true);
AsyncPollingHelper helper = new AsyncPollingHelper(driver);
try {
helper.beginPolling();
Thread.sleep(2500);
System.out.println("***Fetching data first 2.5 seconds***");
Buffer buffer = helper.getFifo();
while(!buffer.isEmpty()){
System.out.println(buffer.remove().toString());
}
Thread.sleep(2500);
System.out.println("***Fetching data second 2.5 seconds***");
while(!buffer.isEmpty()){
System.out.println(buffer.remove().toString());
}
helper.endPolling();
System.out.println("***Fetching final data***");
while(!buffer.isEmpty()){
System.out.println(buffer.remove().toString());
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
示例3: extract
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
/**
* Extracts the weak components from a graph.
* @param aGraph the graph whose weak components are to be extracted
* @return the list of weak components
*/
public ClusterSet extract(ArchetypeGraph aGraph) {
ClusterSet clusterSet = new VertexClusterSet(aGraph);
HashSet unvisitedVertices = new HashSet();
for (Iterator vIt=aGraph.getVertices().iterator(); vIt.hasNext();) {
unvisitedVertices.add(vIt.next());
}
while (!unvisitedVertices.isEmpty()) {
Set weakComponentSet = new HashSet();
ArchetypeVertex root = (ArchetypeVertex) unvisitedVertices.iterator().next();
unvisitedVertices.remove(root);
weakComponentSet.add(root);
Buffer queue = new UnboundedFifoBuffer();
queue.add(root);
while (!queue.isEmpty()) {
ArchetypeVertex currentVertex = (ArchetypeVertex) queue.remove();
Set neighbors = currentVertex.getNeighbors();
for (Iterator nIt = neighbors.iterator(); nIt.hasNext();) {
ArchetypeVertex neighbor = (ArchetypeVertex) nIt.next();
if (unvisitedVertices.contains(neighbor)) {
queue.add(neighbor);
unvisitedVertices.remove(neighbor);
weakComponentSet.add(neighbor);
}
}
}
clusterSet.addCluster(weakComponentSet);
}
return clusterSet;
}
示例4: getFifo
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
public Buffer getFifo() {
return fifo;
}
示例5: getNotifications
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
public Buffer getNotifications() {
return list;
}
示例6: setQueue
import org.apache.commons.collections.Buffer; //导入依赖的package包/类
/**
* Sets the queue of tasks.
*
* @param queue blocking queue of tasks.
*/
public void setQueue(Buffer queue) {
this.tasksQueue = queue;
}