本文整理了Java中java.util.LinkedList.size()
方法的一些代码示例,展示了LinkedList.size()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.size()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:size
[英]Number of nodes currently present in the list.
[中]列表中当前存在的节点数。
代码示例来源:origin: org.mockito/mockito-core
public Object answer(InvocationOnMock invocation) throws Throwable {
if (elements.size() == 1)
return elements.get(0);
else
return elements.poll();
}
}
代码示例来源:origin: hibernate/hibernate-orm
private AST pop() {
if ( parents.size() == 0 ) {
return null;
}
else {
return parents.removeFirst();
}
}
代码示例来源:origin: alibaba/nacos
private int peekStatus(LinkedList statusStack) {
if (statusStack.size() == 0) {
return -1;
}
Integer status = (Integer)statusStack.getFirst();
return status.intValue();
}
代码示例来源:origin: quartz-scheduler/quartz
private String[] split(String str, String splitStr) // Same as String.split(.) in JDK 1.4
{
LinkedList<String> l = new LinkedList<String>();
StringTokenizer strTok = new StringTokenizer(str, splitStr);
while(strTok.hasMoreTokens()) {
String tok = strTok.nextToken();
l.add(tok);
}
return (String[])l.toArray(new String[l.size()]);
}
代码示例来源:origin: spring-projects/spring-framework
LinkedList<String> pathElements = new LinkedList<>();
int tops = 0;
pathElements.add(0, element);
pathElements.add(0, TOP_PATH);
if (pathElements.size() == 1 && "".equals(pathElements.getLast()) && !prefix.endsWith(FOLDER_SEPARATOR)) {
pathElements.add(0, CURRENT_PATH);
代码示例来源:origin: apache/ignite
@Nullable @Override public Object call() throws Exception {
String thNm = Thread.currentThread().getName();
LinkedList<Integer> keys = new LinkedList<>();
LinkedList<Integer> old = res.put(thNm, keys);
assert old == null;
while (true) {
Integer key = keyGen.getAndIncrement();
if (key >= keyCnt)
break;
map.put(key, "value");
keys.add(key);
if (keys.size() > rememberCnt)
keys.removeFirst();
}
return null;
}
},
代码示例来源:origin: apache/incubator-dubbo
Integer old = index;
if (index == null) {
index = history.size() - 1;
} else {
if (up) {
index = index - 1;
if (index < 0) {
index = history.size() - 1;
if (index > history.size() - 1) {
index = 0;
String value = history.get(index);
if (old != null && old >= 0 && old < history.size()) {
String ov = history.get(old);
StringBuilder buf = new StringBuilder();
for (int i = 0; i < ov.length(); i++) {
Integer index = (Integer) channel.getAttribute(HISTORY_INDEX_KEY);
channel.removeAttribute(HISTORY_INDEX_KEY);
if (CollectionUtils.isNotEmpty(history) && index != null && index >= 0 && index < history.size()) {
String value = history.get(index);
if (value != null) {
byte[] b1 = value.getBytes();
if (history.isEmpty()) {
history.addLast(result);
} else if (!result.equals(history.getLast())) {
history.remove(result);
代码示例来源:origin: Sable/soot
private void finder1(PegCallGraph pcg) {
Set clinitMethods = pcg.getClinitMethods();
Iterator it = pcg.iterator();
while (it.hasNext()) {
Object head = it.next();
// breadth first scan
Set<Object> gray = new HashSet<Object>();
LinkedList<Object> queue = new LinkedList<Object>();
queue.add(head);
while (queue.size() > 0) {
Object root = queue.getFirst();
Iterator succsIt = pcg.getSuccsOf(root).iterator();
while (succsIt.hasNext()) {
Object succ = succsIt.next();
if (!gray.contains(succ)) {
gray.add(succ);
queue.addLast(succ);
} else if (clinitMethods.contains(succ)) {
continue;
} else {
multiCalledMethods.add((SootMethod) succ);
}
}
queue.remove(root);
}
}
}
代码示例来源:origin: apache/rocketmq
public void samplingInMinutes() {
synchronized (this.csListHour) {
this.csListHour.add(new CallSnapshot(System.currentTimeMillis(), this.times.get(), this.value
.get()));
if (this.csListHour.size() > 7) {
this.csListHour.removeFirst();
}
}
}
代码示例来源:origin: iSoron/uhabits
public String getLogcat() throws IOException
{
int maxLineCount = 250;
StringBuilder builder = new StringBuilder();
String[] command = new String[]{ "logcat", "-d" };
java.lang.Process process = Runtime.getRuntime().exec(command);
InputStreamReader in = new InputStreamReader(process.getInputStream());
BufferedReader bufferedReader = new BufferedReader(in);
LinkedList<String> log = new LinkedList<>();
String line;
while ((line = bufferedReader.readLine()) != null)
{
log.addLast(line);
if (log.size() > maxLineCount) log.removeFirst();
}
for (String l : log)
{
builder.append(l);
builder.append('\n');
}
return builder.toString();
}
代码示例来源:origin: org.netbeans.api/org-openide-util
/** duplicate state */
State(State original) {
items = new LinkedList<Item>();
itemIndex = new HashMap<String,Item>(original.items.size() * 4 / 3 + 1);
for (Item _i : original.items) {
Item i = (Item) _i.clone();
items.add(i);
itemIndex.put(i.getKey(), i);
}
}
}
代码示例来源:origin: shekhargulati/99-problems
public static <T> T secondLastRecursion(LinkedList<T> list) {
if (list.size() < 2) {
throw new NoSuchElementException("Can't find secondLast element from a list with less than 2 elements");
}
if (list.size() == 2) {
return list.getFirst();
}
return secondLastRecursion(new LinkedList<>(list.subList(1, list.size())));
}
}
代码示例来源:origin: naman14/Timber
public void setAndRecordPlayPos(int nextPos) {
synchronized (this) {
if (mShuffleMode != SHUFFLE_NONE) {
mHistory.add(mPlayPos);
if (mHistory.size() > MAX_HISTORY_SIZE) {
mHistory.remove(0);
}
}
mPlayPos = nextPos;
}
}
代码示例来源:origin: ethereum/ethereumj
private synchronized boolean onTransactions(List<Transaction> txs) {
if (txs.isEmpty()) return false;
long[] gasPrices = new long[txs.size()];
for (int i = 0; i < txs.size(); ++i) {
gasPrices[i] = ByteUtil.byteArrayToLong(txs.get(i).getGasPrice());
}
blockGasPrices.add(gasPrices);
while (blockGasPrices.size() > getMinBlocks() &&
(calcGasPricesSize() - blockGasPrices.getFirst().length) >= getMinTransactions()) {
blockGasPrices.removeFirst();
}
return true;
}
代码示例来源:origin: apache/kylin
AggrKey(byte[] groupByMask) {
this.groupByMask = groupByMask;
LinkedList<Integer> list = Lists.newLinkedList();
for (int i = 0; i < groupByMask.length; i++) {
if (groupByMask[i] != 0) {
list.add(i);
}
}
groupByMaskSet = new int[list.size()];
for (int i = 0; i < list.size(); i++) {
groupByMaskSet[i] = list.get(i);
}
}
代码示例来源:origin: apache/rocketmq
@Override
public void run() {
snapshotList.addLast(statsBenchmark.createSnapshot());
if (snapshotList.size() > 10) {
snapshotList.removeFirst();
}
}
}, 1000, 1000);
代码示例来源:origin: org.codehaus.jackson/jackson-mapper-asl
public AnnotatedMethod getAnySetterMethod()
{
if (_anySetters != null) {
if (_anySetters.size() > 1) {
reportProblem("Multiple 'any-setters' defined ("+_anySetters.get(0)+" vs "
+_anySetters.get(1)+")");
}
return _anySetters.getFirst();
}
return null;
}
代码示例来源:origin: org.apache.spark/spark-core_2.10
int nextIdx = dataPages.indexOf(currentPage) + 1;
if (destructive && currentPage != null) {
dataPages.remove(currentPage);
freePage(currentPage);
nextIdx --;
if (dataPages.size() > nextIdx) {
currentPage = dataPages.get(nextIdx);
pageBaseObject = currentPage.getBaseObject();
offsetInPage = currentPage.getBaseOffset();
if (reader != null) {
File file = spillWriters.removeFirst().getFile();
if (file != null && file.exists()) {
if (!file.delete()) {
reader = spillWriters.getFirst().getReader(serializerManager);
recordsInPage = -1;
} catch (IOException e) {
代码示例来源:origin: jfinal/jfinal
private static synchronized void addFieldGetter(FieldGetter fieldGetter, Integer index, boolean addLast) {
checkParameter(fieldGetter);
LinkedList<FieldGetter> ret = getCurrentFieldGetters();
if (index != null) {
ret.add(index, fieldGetter);
} else {
if (addLast) {
ret.addLast(fieldGetter);
} else {
ret.addFirst(fieldGetter);
}
}
getters = ret.toArray(new FieldGetter[ret.size()]);
}
代码示例来源:origin: apache/hbase
HRegionInfo dri = regionLocator.getRegionLocation(split).getRegionInfo();
if (dri.isOffline() || !Bytes.equals(dri.getStartKey(), split)) {
logicalSplitting.add(region);
continue;
logicalSplitting.add(region);
continue;
check.add(regionLocator.getRegionLocation(start).getRegionInfo());
check.add(regionLocator.getRegionLocation(split).getRegionInfo());
for (HRegionInfo hri : check.toArray(new HRegionInfo[check.size()])) {
byte[] sk = hri.getStartKey();
if (sk.length == 0)
check.remove(hri);
if (check.isEmpty()) {
finished.add(region);
} else {
LOG.debug("Split Scan: " + finished.size() + " finished / "
+ logicalSplitting.size() + " split wait / "
+ physicalSplitting.size() + " reference wait");
内容来源于网络,如有侵权,请联系作者删除!