本文整理汇总了Java中java.util.LinkedList.listIterator方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.listIterator方法的具体用法?Java LinkedList.listIterator怎么用?Java LinkedList.listIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.listIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import java.util.LinkedList; //导入方法依赖的package包/类
public synchronized AuthCacheValue get (String pkey, String skey) {
AuthenticationInfo result = null;
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
if (list == null || list.size() == 0) {
return null;
}
if (skey == null) {
// list should contain only one element
return (AuthenticationInfo)list.get (0);
}
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (skey.startsWith (inf.path)) {
return inf;
}
}
return null;
}
示例2: put
import java.util.LinkedList; //导入方法依赖的package包/类
public synchronized void put (String pkey, AuthCacheValue value) {
LinkedList<AuthCacheValue> list = hashtable.get (pkey);
String skey = value.getPath();
if (list == null) {
list = new LinkedList<AuthCacheValue>();
hashtable.put(pkey, list);
}
// Check if the path already exists or a super-set of it exists
ListIterator<AuthCacheValue> iter = list.listIterator();
while (iter.hasNext()) {
AuthenticationInfo inf = (AuthenticationInfo)iter.next();
if (inf.path == null || inf.path.startsWith (skey)) {
iter.remove ();
}
}
iter.add(value);
}
示例3: mergeTo
import java.util.LinkedList; //导入方法依赖的package包/类
private static <T> void mergeTo(List<T> fromList, LinkedList<T> toList, Comparator<T> comparator) {
if (fromList.isEmpty()) {
return;
}
Iterator<T> fromIterator = fromList.iterator();
ListIterator<T> toIterator = toList.listIterator();
T currentFromElement = null;
if (toIterator.hasNext()) {
currentFromElement = fromIterator.next();
while (currentFromElement != null && toIterator.hasNext()) {
if (comparator.compare(toIterator.next(), currentFromElement) > 0) {
toIterator.previous();
toIterator.add(currentFromElement);
currentFromElement = fromIterator.hasNext() ? fromIterator.next() : null;
}
}
}
if (currentFromElement != null) {
toList.add(currentFromElement);
}
while (fromIterator.hasNext()) {
toList.add(fromIterator.next());
}
}
示例4: main
import java.util.LinkedList; //导入方法依赖的package包/类
public static
void main(String[] args) {
LinkedList list = new LinkedList();
ListIterator e = list.listIterator();
Object o = new Integer(1);
e.add(o);
e.previous();
e.next();
e.remove();
e.add(o);
if (!o.equals(list.get(0)))
throw new RuntimeException("LinkedList ListIterator remove failed.");
}
示例5: findSendablePacket
import java.util.LinkedList; //导入方法依赖的package包/类
private Packet findSendablePacket(LinkedList<Packet> outgoingQueue,
boolean clientTunneledAuthenticationInProgress) {
synchronized (outgoingQueue) {
if (outgoingQueue.isEmpty()) {
return null;
}
if (outgoingQueue.getFirst().bb != null // If we've already starting sending the first packet, we better finish
|| !clientTunneledAuthenticationInProgress) {
return outgoingQueue.getFirst();
}
// Since client's authentication with server is in progress,
// send only the null-header packet queued by primeConnection().
// This packet must be sent so that the SASL authentication process
// can proceed, but all other packets should wait until
// SASL authentication completes.
ListIterator<Packet> iter = outgoingQueue.listIterator();
while (iter.hasNext()) {
Packet p = iter.next();
if (p.requestHeader == null) {
// We've found the priming-packet. Move it to the beginning of the queue.
iter.remove();
outgoingQueue.add(0, p);
return p;
} else {
// Non-priming packet: defer it until later, leaving it in the queue
// until authentication completes.
if (LOG.isDebugEnabled()) {
LOG.debug("deferring non-priming packet: " + p +
"until SASL authentication completes.");
}
}
}
// no sendable packet found.
return null;
}
}
示例6: prune
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Prunes the given list of hypothesis. All hypothesis with an upper utility bound less than the
* parameter minUtility is pruned.
*/
public LinkedList<Hypothesis> prune(LinkedList<Hypothesis> hypoList, double minUtility, double totalWeight,
double totalPositiveWeight, double delta_p) {
double delta_hp = delta_p / hypoList.size();
ListIterator it = hypoList.listIterator();
while (it.hasNext()) {
Hypothesis hypo = (Hypothesis) it.next();
double upperBound = theUtility.getUpperBound(totalWeight, totalPositiveWeight, hypo, delta_hp);
if (upperBound < minUtility) {
it.remove();
}
}
return hypoList;
}
示例7: processTimerList
import java.util.LinkedList; //导入方法依赖的package包/类
private void processTimerList( LinkedList<TimerWheelTimer> pList ){
ListIterator<TimerWheelTimer> ExpiredTimer = pList.listIterator();
while (ExpiredTimer.hasNext()){
try{
ExpiredTimer.next().getExpiryFunction().invoke(expiryObject, expiryData);
ExpiredTimer.remove();
numberOfTimers--;
}catch(Exception e){
e.printStackTrace();
}
}
pList.clear();
}
示例8: doPurge
import java.util.LinkedList; //导入方法依赖的package包/类
private void doPurge(Call call, long now) {
LinkedList<Call> responseQueue = call.connection.responseQueue;
synchronized (responseQueue) {
Iterator<Call> iter = responseQueue.listIterator(0);
while (iter.hasNext()) {
call = iter.next();
if (now > call.timestamp + PURGE_INTERVAL) {
closeConnection(call.connection);
break;
}
}
}
}
示例9: getHeaderNames
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Get the header names.
*
* @return a list iterator to a list of header names. These are ordered in the same order as
* are present in the message.
*/
public ListIterator<String> getHeaderNames() {
Iterator<SIPHeader> li = this.headers.iterator();
LinkedList<String> retval = new LinkedList<String>();
while (li.hasNext()) {
SIPHeader sipHeader = (SIPHeader) li.next();
String name = sipHeader.getName();
retval.add(name);
}
return retval.listIterator();
}
示例10: packOptionalTlv
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Returns writer index.
*
* @param cb of type channel buffer.
* @return writer index
*/
protected int packOptionalTlv(ChannelBuffer cb) {
int startIndex = cb.writerIndex();
LinkedList<PcepValueType> llOptionalTlv = this.llOptionalTlv;
ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
if (tlv == null) {
log.debug("TLV is null from OptionalTlv list");
continue;
}
tlv.write(cb);
// need to take care of padding
int pad = tlv.getLength() % 4;
if (0 != pad) {
pad = 4 - pad;
for (int i = 0; i < pad; ++i) {
cb.writeByte((byte) 0);
}
}
}
return cb.writerIndex() - startIndex;
}
示例11: capabilityNegotiation
import java.util.LinkedList; //导入方法依赖的package包/类
private void capabilityNegotiation(PcepOpenMsg pOpenmsg) {
LinkedList<PcepValueType> tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv();
boolean pceccCapability = false;
boolean statefulPceCapability = false;
boolean pcInstantiationCapability = false;
boolean labelStackCapability = false;
boolean srCapability = false;
ListIterator<PcepValueType> listIterator = tlvList.listIterator();
while (listIterator.hasNext()) {
PcepValueType tlv = listIterator.next();
switch (tlv.getType()) {
case PceccCapabilityTlv.TYPE:
pceccCapability = true;
if (((PceccCapabilityTlv) tlv).sBit()) {
labelStackCapability = true;
}
break;
case StatefulPceCapabilityTlv.TYPE:
statefulPceCapability = true;
StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv;
if (stetefulPcCapTlv.getIFlag()) {
pcInstantiationCapability = true;
}
break;
case SrPceCapabilityTlv.TYPE:
srCapability = true;
break;
default:
continue;
}
}
this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability,
labelStackCapability, srCapability);
}
示例12: getNextHops
import java.util.LinkedList; //导入方法依赖的package包/类
public ListIterator getNextHops(Request request) {
URI uri = request.getRequestURI();
ScenarioHarness.assertTrue("Expected to be consulted only for tel uri",uri.getScheme().equals("tel"));
LinkedList llist = new LinkedList();
llist.add(new HopImpl());
return llist.listIterator();
}
示例13: lookUpList
import java.util.LinkedList; //导入方法依赖的package包/类
public static UnknownVariable lookUpList(String strName, LinkedList<UnknownVariable> lUnknownVars) {
ListIterator<UnknownVariable> itr = lUnknownVars.listIterator();
String strLowerCaseName = strName.toLowerCase(Locale.US);
while (itr.hasNext()) {
UnknownVariable var = itr.next();
if(var.getName().equals(strLowerCaseName)) {
return var;
}
}
return null;
}
示例14: diff_lineMode
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Do a quick line-level diff on both strings, then rediff the parts for
* greater accuracy.
* This speedup can produce non-minimal diffs.
* @param text1 Old string to be diffed.
* @param text2 New string to be diffed.
* @param deadline Time when the diff should be complete by.
* @return Linked List of Diff objects.
*/
private LinkedList<Diff> diff_lineMode(String text1, String text2,
long deadline) {
// Scan the text on a line-by-line basis first.
LinesToCharsResult b = diff_linesToChars(text1, text2);
text1 = b.chars1;
text2 = b.chars2;
List<String> linearray = b.lineArray;
LinkedList<Diff> diffs = diff_main(text1, text2, false, deadline);
// Convert the diff back to original text.
diff_charsToLines(diffs, linearray);
// Eliminate freak matches (e.g. blank lines)
diff_cleanupSemantic(diffs);
// Rediff any replacement blocks, this time character-by-character.
// Add a dummy entry at the end.
diffs.add(new Diff(Operation.EQUAL, ""));
int count_delete = 0;
int count_insert = 0;
String text_delete = "";
String text_insert = "";
ListIterator<Diff> pointer = diffs.listIterator();
Diff thisDiff = pointer.next();
while (thisDiff != null) {
switch (thisDiff.operation) {
case INSERT:
count_insert++;
text_insert += thisDiff.text;
break;
case DELETE:
count_delete++;
text_delete += thisDiff.text;
break;
case EQUAL:
// Upon reaching an equality, check for prior redundancies.
if (count_delete >= 1 && count_insert >= 1) {
// Delete the offending records and add the merged ones.
pointer.previous();
for (int j = 0; j < count_delete + count_insert; j++) {
pointer.previous();
pointer.remove();
}
for (Diff newDiff : diff_main(text_delete, text_insert, false,
deadline)) {
pointer.add(newDiff);
}
}
count_insert = 0;
count_delete = 0;
text_delete = "";
text_insert = "";
break;
}
thisDiff = pointer.hasNext() ? pointer.next() : null;
}
diffs.removeLast(); // Remove the dummy entry at the end.
return diffs;
}
示例15: parseFile
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Parses a file and returns a TimeSeries of type Accel object.
*/
public TimeSeries<Accel> parseFile(String filename) {
try {
BufferedReader br = new BufferedReader(new FileReader(filename));
String line;
LinkedList<String> lineList = new LinkedList<String>();
while ((line = br.readLine()) != null) {
lineList.add(line);
}
ListIterator<String> listIterator = lineList.listIterator();
LinkedList<Accel> interval = new LinkedList<Accel>();
TimeSeries<Accel> ts = new TimeSeries<Accel>();
int intervalStart = 0;
boolean record = false;
String flag = "";
while (listIterator.hasNext()) {
line = listIterator.next();
String[] split = line.split(" ");
int time = Integer.parseInt(split[0]);
if (split[1].equals("START")) {
if (split[2].equals("17")) {
record = false;
}
flag = split[2];
} else if (split[1].equals("END")) {
if (split[2].equals("0")) {
record = true;
intervalStart = time;
}
flag = "";
} else if (record) {
if (time < intervalStart + 50) {
interval.add(
new Accel(
Integer.parseInt(split[1]),
Integer.parseInt(split[2]),
Integer.parseInt(split[3])
)
);
} else {
if (interval.isEmpty()) {
throw new IllegalArgumentException("Record is incomplete.");
}
ts.add(new Point<Accel>(this.meanAccel(interval), flag));
interval = new LinkedList<Accel>();
intervalStart += 30;
boolean backInTime = true;
while (listIterator.hasPrevious() && backInTime) {
String[] prevSplit = listIterator.previous().split(" ");
if (Integer.parseInt(prevSplit[0]) < intervalStart) {
backInTime = false;
}
}
listIterator.next();
}
}
}
if (!interval.isEmpty()) {
ts.add(new Point<Accel>(this.meanAccel(interval), flag));
}
return ts;
} catch (Exception exception) {
return null;
}
}