本文整理汇总了Java中java.util.ListIterator.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java ListIterator.hasNext方法的具体用法?Java ListIterator.hasNext怎么用?Java ListIterator.hasNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ListIterator
的用法示例。
在下文中一共展示了ListIterator.hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: remove
import java.util.ListIterator; //导入方法依赖的package包/类
public synchronized void remove (String pkey, AuthCacheValue entry) {
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null) {
return;
}
if (entry == null) {
list.clear();
return;
}
ListIterator<AuthCacheValue> iter = list.listIterator ();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (entry.equals(inf)) {
iter.remove ();
}
}
}
示例2: getServiceFunctions
import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public List<ServiceFunctionGroup> getServiceFunctions(PortChainId portChainId) {
List<ServiceFunctionGroup> serviceFunctionGroupList = Lists.newArrayList();
PortChain portChain = portChainService.getPortChain(portChainId);
// Go through the port pair group list
List<PortPairGroupId> portPairGrpList = portChain.portPairGroups();
ListIterator<PortPairGroupId> listGrpIterator = portPairGrpList.listIterator();
while (listGrpIterator.hasNext()) {
PortPairGroupId portPairGroupId = listGrpIterator.next();
PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId);
ServiceFunctionGroup sfg = new ServiceFunctionGroup(portPairGroup.name(), portPairGroup.description(),
portPairGroup.portPairLoadMap());
serviceFunctionGroupList.add(sfg);
}
return ImmutableList.copyOf(serviceFunctionGroupList);
}
示例3: removeAnimatedEventFromView
import java.util.ListIterator; //导入方法依赖的package包/类
public void removeAnimatedEventFromView(int viewTag, String eventName, int animatedValueTag) {
String key = viewTag + eventName;
if (mEventDrivers.containsKey(key)) {
List<EventAnimationDriver> driversForKey = mEventDrivers.get(key);
if (driversForKey.size() == 1) {
mEventDrivers.remove(viewTag + eventName);
} else {
ListIterator<EventAnimationDriver> it = driversForKey.listIterator();
while (it.hasNext()) {
if (it.next().mValueNode.mTag == animatedValueTag) {
it.remove();
break;
}
}
}
}
}
示例4: searchForwards
import java.util.ListIterator; //导入方法依赖的package包/类
public int searchForwards(String searchTerm, int startIndex, boolean startsWith) {
if (startIndex >= history.size()) {
startIndex = history.size() - 1;
}
ListIterator<History.Entry> it = history.entries(startIndex);
if (searchIndex != -1 && it.hasNext()) {
it.next();
}
while (it.hasNext()) {
History.Entry e = it.next();
if (startsWith) {
if (e.value().toString().startsWith(searchTerm)) {
return e.index();
}
} else {
if (e.value().toString().contains(searchTerm)) {
return e.index();
}
}
}
return -1;
}
示例5: cull
import java.util.ListIterator; //导入方法依赖的package包/类
void cull(int origin) {
// See RegionManager.cull() for culling strategy.
// This function isn't recursive. It's called only once on root.
if (children == null) {
return;
}
int nculled = 0;
ListIterator<ActiveRegion> iter = children.listIterator();
while (iter.hasNext()) {
ActiveRegion child = iter.next();
if (child.begin.row < origin) {
iter.remove();
nculled++;
} else {
break; // short circuit out
}
}
// System.out.println("cull'ed " + nculled + " regions"); // NOI18N
}
示例6: write
import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public int write(ChannelBuffer cb) throws PcepParseException {
//write Object header
int objStartIndex = cb.writerIndex();
int objLenIndex = rroObjHeader.write(cb);
if (objLenIndex <= 0) {
throw new PcepParseException(" object Length Index" + objLenIndex);
}
ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
while (listIterator.hasNext()) {
listIterator.next().write(cb);
}
//Update object length now
int length = cb.writerIndex() - objStartIndex;
cb.setShort(objLenIndex, (short) length);
//will be helpful during print().
rroObjHeader.setObjLen((short) length);
//As per RFC the length of object should be multiples of 4
int pad = length % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; i++) {
cb.writeByte((byte) 0);
}
length = length + pad;
}
objLenIndex = cb.writerIndex();
return objLenIndex;
}
示例7: run
import java.util.ListIterator; //导入方法依赖的package包/类
/** This is the run method of the NetController (thread). */
public void run() throws InterruptedException, NetException {
SimSystem.runStart();
startTime = NetSystem.getElapsedTime();
while (SimSystem.runTick()) {
synchronized (this) {
//the presence of this "if" allows pause control
if (blocked) {
wait();
}
n++;
if (n % refreshPeriod == 0) {
//User may have defined measures that will not receive any sample
if (n % reachabilityTest == 0) {
//stop measures which have not collected samples yet
NetSystem.stopNoSamplesMeasures();
}
//refresh measures
NetSystem.checkMeasures();
}
//check if a positive max simulated time is set and has been reached for the first time
if (maxSimulatedTime > 0 && SimSystem.getClock() > maxSimulatedTime && !aborting) {
ListIterator<QueueNetwork> nets = NetSystem.getNetworkList().listIterator();
QueueNetwork network;
while (nets.hasNext()) {
network = nets.next();
network.abortAllMeasures();
aborting = true;
}
NetSystem.checkMeasures(); //refresh measures, this triggers a simulation stop because all measures have been aborted
}
}
}
//sim is finished: get stop time
stopTime = NetSystem.getElapsedTime();
SimSystem.runStop();
running = false;
}
示例8: renderMethodCFG
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Renders the method CFG, sets the {@link #CFG} to true and pans the graph to the first node of the graph based on the value of {@code panToNode}.
*
* @param cfg
* @param panToNode
* @throws Exception
* @author Shashank B S
*/
private void renderMethodCFG(ControlFlowGraph cfg, boolean panToNode) throws Exception {
if (cfg == null)
throw new Exception("GraphStructure is null");
this.reintializeGraph();
ListIterator<VFEdge> edgeIterator = cfg.listEdges.listIterator();
while (edgeIterator.hasNext()) {
VFEdge currEdgeIterator = edgeIterator.next();
VFNode src = currEdgeIterator.getSource();
VFNode dest = currEdgeIterator.getDestination();
createControlFlowGraphNode(src);
createControlFlowGraphNode(dest);
createControlFlowGraphEdge(src, dest);
}
if (cfg.listEdges.size() == 1) {
VFNode node = cfg.listNodes.get(0);
createControlFlowGraphNode(node);
}
this.CFG = true;
experimentalLayout();
if (panToNode) {
defaultPanZoom();
panToNode(graph.getNodeIterator().next().getId());
}
this.header.setText("Method CFG ----> " + ServiceUtil.getService(DataModel.class).getSelectedMethod().toString());
}
示例9: removeMarkedBlocks
import java.util.ListIterator; //导入方法依赖的package包/类
public void removeMarkedBlocks() {
ListIterator<BasicBlock> blockIterator = listIterator();
while (blockIterator.hasNext()) {
BasicBlock block = blockIterator.next();
if (block.isMarked()) {
blockIterator.remove();
if (block == normalExitBlock) {
normalExitBlock = null;
}
}
}
}
示例10: matchChar
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Matches the specified character.
* @param c
*/
public void matchChar(char c) {
if (end.accept(last, c))
endMatches();
if (charPos)
position++;
if (start.accept(last, c))
startMatch();
if (!filter.accept(last, c)) {
last = c;
return;
}
ListIterator<Match<T>> lit = pending.listIterator();
while (lit.hasNext()) {
Match<T> m = lit.next();
char mc = mapper.map(last, c);
State<T> s = m.getState().getChild(mc);
if (s == null)
lit.remove();
else {
if (visitedStates != null)
visitedStates.add(s);
m.setState(s);
}
}
last = c;
}
示例11: trimLeadingIndent
import java.util.ListIterator; //导入方法依赖的package包/类
static List<Term> trimLeadingIndent(List<Term> code) {
ArrayList<Term> result = new ArrayList<>(code);
ListIterator<Term> it = result.listIterator();
while (it.hasNext()) {
Term t = it.next();
if (t.isWhitespace()) {
String whitespace = t.toString();
int indexOf = whitespace.indexOf('\n');
if (indexOf >= 0) {
it.set(new Whitespace(whitespace.substring(0, indexOf + 1)));
}
}
}
return result;
}
示例12: testDeSerializeBad1
import java.util.ListIterator; //导入方法依赖的package包/类
public void testDeSerializeBad1() {
Ethernet eth = new Ethernet();
eth.deserialize(dhcpPacketBadOption1, 0, dhcpPacketBadOption1.length);
assertTrue(eth.getPayload() instanceof IPv4);
IPv4 ipv4 = (IPv4) eth.getPayload();
assertTrue(ipv4.getPayload() instanceof UDP);
UDP udp = (UDP) ipv4.getPayload();
assertTrue(udp.getPayload() instanceof DHCP);
DHCP dhcp = (DHCP) udp.getPayload();
/** The invalid option in DHCP packet is dropped. Reset checksums and
* length field so that the serialize() function can re-compute them
*/
resetChecksumsAndLengths(ipv4, udp);
assertEquals(DHCP.OPCODE_REPLY, dhcp.getOpCode());
ListIterator<DHCPOption> lit = dhcp.getOptions().listIterator();
// Expect 5 correct options and an END option.
assertEquals(dhcp.getOptions().size(), 6);
while (lit.hasNext()) {
DHCPOption option = lit.next();
assertFalse(option.code == (byte)0x0c);
}
byte[] result = eth.serialize();
// Since one option is badly formated, the result is different.
assertFalse(Arrays.equals(this.dhcpPacketPXE, result));
}
示例13: replaceValues
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*
* <p>If any entries for the specified {@code key} already exist in the
* multimap, their values are changed in-place without affecting the iteration
* order.
*
* <p>The returned list is immutable and implements
* {@link java.util.RandomAccess}.
*/
@CanIgnoreReturnValue
@Override
public List<V> replaceValues(@Nullable K key, Iterable<? extends V> values) {
List<V> oldValues = getCopy(key);
ListIterator<V> keyValues = new ValueForKeyIterator(key);
Iterator<? extends V> newValues = values.iterator();
// Replace existing values, if any.
while (keyValues.hasNext() && newValues.hasNext()) {
keyValues.next();
keyValues.set(newValues.next());
}
// Remove remaining old values, if any.
while (keyValues.hasNext()) {
keyValues.next();
keyValues.remove();
}
// Add remaining new values, if any.
while (newValues.hasNext()) {
keyValues.add(newValues.next());
}
return oldValues;
}
示例14: onTrigger
import java.util.ListIterator; //导入方法依赖的package包/类
@Override
public void onTrigger(final ProcessContext context, final ProcessSession processSession) {
List<FlowFile> flowFiles = processSession.get(batchSize);
if (flowFiles.isEmpty()) {
return;
}
Session jschSession = null;
Channel channel = null;
try {
jschSession = openSession(context);
final String remotePath = context.getProperty(REMOTE_PATH).evaluateAttributeExpressions().getValue();
channel = openExecChannel(context, jschSession, "scp -r -d -t " + remotePath);
InputStream channelIn = channel.getInputStream();
OutputStream channelOut = channel.getOutputStream();
channel.connect();
waitForAck(channelIn);
ListIterator<FlowFile> fileIt = flowFiles.listIterator();
while (fileIt.hasNext()) {
final FlowFile flowFile = fileIt.next();
// conditionally reject files that are zero bytes or less
if (context.getProperty(REJECT_ZERO_BYTE).asBoolean() && flowFile.getSize() == 0) {
logger.warn("Rejecting {} because it is zero bytes", new Object[]{flowFile});
processSession.transfer(processSession.penalize(flowFile), REL_REJECT);
fileIt.remove();
continue;
}
final String filename = flowFile.getAttribute(CoreAttributes.FILENAME.key());
final String permissions = context.getProperty(PERMISSIONS).evaluateAttributeExpressions(flowFile).getValue();
// destination path + filename
// final String fullPath = buildFullPath(context, flowFile, filename);
processSession.read(flowFile, new InputStreamCallback() {
@Override
public void process(final InputStream flowFileIn) throws IOException {
// send "C0644 filesize filename", where filename should not include '/'
StringBuilder command = new StringBuilder("C").append(permissions).append(' ');
command.append(flowFile.getSize()).append(' ');
command.append(filename).append('\n');
channelOut.write(command.toString().getBytes(StandardCharsets.UTF_8));
channelOut.flush();
waitForAck(channelIn);
IOUtils.copy(flowFileIn, channelOut);
channelOut.flush();
sendAck(channelOut);
waitForAck(channelIn);
}
});
processSession.transfer(flowFile, REL_SUCCESS);
processSession.getProvenanceReporter().send(flowFile, remotePath);
fileIt.remove();
if (logger.isDebugEnabled()) {
logger.debug("Sent {} to remote host", new Object[]{flowFile});
}
}
} catch (JSchException | IOException ex) {
context.yield();
logger.error("Unable to create session to remote host due to {}", new Object[]{ex}, ex);
processSession.transfer(flowFiles, REL_FAILURE);
} finally {
if (channel != null) {
channel.disconnect();
}
if (jschSession != null) {
jschSession.disconnect();
}
}
}
示例15: filterProblemsInVirtualCode
import java.util.ListIterator; //导入方法依赖的package包/类
private static void filterProblemsInVirtualCode(Snapshot snapshot, List<ProblemDescription> problems) {
ListIterator<ProblemDescription> listIterator = problems.listIterator();
while (listIterator.hasNext()) {
ProblemDescription p = listIterator.next();
int from = p.getFrom();
int to = p.getTo();
if (snapshot.getOriginalOffset(from) == -1 || snapshot.getOriginalOffset(to) == -1) {
listIterator.remove();
}
}
}