本文整理了Java中java.util.LinkedList.get()
方法的一些代码示例,展示了LinkedList.get()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.get()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:get
[英]Returns the element at the specified position in this 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: org.codehaus.jackson/jackson-mapper-asl
public AnnotatedMethod getAnyGetterMethod()
{
if (_anyGetters != null) {
if (_anyGetters.size() > 1) {
reportProblem("Multiple 'any-getters' defined ("+_anyGetters.get(0)+" vs "
+_anyGetters.get(1)+")");
}
return _anyGetters.getFirst();
}
return null;
}
代码示例来源:origin: apache/rocketmq
private String getPutTps(int time) {
String result = "";
this.lockSampling.lock();
try {
CallSnapshot last = this.putTimesList.getLast();
if (this.putTimesList.size() > time) {
CallSnapshot lastBefore = this.putTimesList.get(this.putTimesList.size() - (time + 1));
result += CallSnapshot.getTPS(lastBefore, last);
}
} finally {
this.lockSampling.unlock();
}
return result;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
public void convertArrayToCollectionImpl() {
LinkedList<?> result = conversionService.convert(new String[] {"1", "2", "3"}, LinkedList.class);
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
assertEquals("3", result.get(2));
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testStoredProcedureOutParameter() throws SQLException {
clearSpies();
doInHibernate( this::sessionFactory, session -> {
Person person = new Person();
person.id = 1L;
person.name = "Vlad Mihalcea";
session.persist( person );
} );
assertEquals( 1, sqlStatementInterceptor.getSqlQueries().size() );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().startsWith( "insert into" ) );
Connection connectionSpy = connectionProvider.getConnectionSpyMap().keySet().iterator().next();
verify( connectionSpy, never() ).setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED );
clearSpies();
doInHibernate( this::sessionFactory, session -> {
Person person = session.find( Person.class, 1L );
assertEquals( "Vlad Mihalcea", person.name );
} );
assertEquals( 1, sqlStatementInterceptor.getSqlQueries().size() );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().startsWith( "select" ) );
connectionSpy = connectionProvider.getConnectionSpyMap().keySet().iterator().next();
verify( connectionSpy, never() ).setTransactionIsolation( Connection.TRANSACTION_READ_COMMITTED );
}
代码示例来源:origin: nutzam/nutz
/**
* 访问头部开始第几个字节, 不删除
* @param index
* @return 头部的第N个字节
* @throws IOException
*/
public int peek(int index) throws IOException{
while(cache.size() <= index){
cache.add(is.read());
}
return cache.get(index);
}
代码示例来源:origin: FudanNLP/fnlp
/**
* 增加新的标签和得分,并根据得分调整排序 *
* @param label 标签
* @param score 得分
* @return 插入位置
*/
public int add(T label,float score) {
int j = 0;
for(; j < labels.size(); j++)
if(scores.get(j) < score){
labels.add(j, label);
scores.add(j,score);
break;
}
if(j == labels.size() && labels.size() < k){
labels.add(j, label);
scores.add(j,score);
}
if(labels.size() > k){
labels.removeLast();
scores.removeLast();
}
return j;
}
代码示例来源:origin: stanfordnlp/CoreNLP
boolean addedBe = false;
boolean addedSuffix = false;
if (body.size() > 1 && !"PRP".equals(body.get(0).tag())) {
for (int i = 2; i < body.size(); ++i) {
CoreLabel tokI = body.get(i);
if (tokI.tag() != null &&
((tokI.tag().startsWith("V") && !tokI.tag().equals("VBD") && !"be".equals(body.get(i - 1).lemma())) ||
(tokI.tag().startsWith("J") && suffix != null) ||
(tokI.tag().startsWith("D") && suffix != null) ||
(tokI.tag().startsWith("R") && suffix != null))) {
body.add(i, be.get(0));
i += 1;
if (suffix != null) {
while (i < body.size() && body.get(i).tag() != null &&
(body.get(i).tag().startsWith("J") || body.get(i).tag().startsWith("V") || body.get(i).tag().startsWith("R") ||
body.get(i).tag().startsWith("N") || body.get(i).tag().startsWith("D")) &&
!body.get(i).tag().equals("VBG")) {
i += 1;
if (body.size() > 1 && "PRP".equals(body.get(0).tag())) {
if (body.size() > 1 && "do".equals(body.get(body.size() - 1).word())) {
while (i >= 1 && body.get(i).tag() != null &&
(body.get(i).tag().startsWith("N") || body.get(i).tag().startsWith("J"))) {
i -= 1;
if (i < body.size() - 1 && body.get(i).tag() != null && body.get(i).tag().startsWith("IN")) {
代码示例来源:origin: tdebatty/java-string-similarity
while (i < offset_arr.size()) {
Offset ofs = offset_arr.get(i);
if (c1 <= ofs.c1 || c2 <= ofs.c2) {
} else {
if (c1 > ofs.c2 && c2 > ofs.c1) {
offset_arr.remove(i);
} else {
i++;
offset_arr.add(new Offset(c1, c2, is_trans));
代码示例来源:origin: neo4j/neo4j
private void makeSureFirstAndLastAreReturnedCorrectly( EntityCreator<PropertyContainer> creator,
TimelineIndex<PropertyContainer> timeline )
{
LinkedList<Pair<PropertyContainer, Long>> timestamps = createTimestamps( creator, timeline, 223456, 12345, 432234 );
try ( Transaction tx = db.beginTx() )
{
assertEquals( timestamps.get( 1 ).first(), timeline.getFirst() );
assertEquals( timestamps.getLast().first(), timeline.getLast() );
tx.success();
}
}
代码示例来源: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();
代码示例来源:origin: apache/incubator-dubbo
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++) {
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();
history.addLast(result);
} else if (!result.equals(history.getLast())) {
history.remove(result);
history.addLast(result);
if (history.size() > 10) {
代码示例来源:origin: FudanNLP/fnlp
/**
* 合并重复标签,有问题(未排序)
*/
public void mergeDuplicate() {
for(int i = 0; i < labels.size(); i++)
for(int j = i + 1; j < labels.size(); j++){
T tagi = labels.get(i);
T tagj = labels.get(j);
if(tagi.equals(tagj)){
scores.set(i, scores.get(i) + scores.get(j));
labels.remove(j);
scores.remove(j);
j--;
}
}
}
代码示例来源:origin: Sable/soot
LinkedList<Integer> pathStackIndex = new LinkedList<Integer>();
pathStack.add(from);
pathStackIndex.add(new Integer(0));
int psiMax = (g.getSuccsOf(pathStack.get(0))).size();
int level = 0;
while (pathStackIndex.get(0).intValue() != psiMax) {
int p = (pathStackIndex.get(level)).intValue();
List<Unit> succs = g.getSuccsOf((pathStack.get(level)));
if (p >= succs.size()) {
pathStack.remove(level);
pathStackIndex.remove(level);
int q = pathStackIndex.get(level).intValue();
pathStackIndex.set(level, new Integer(q + 1));
continue;
pathStack.add(to);
return pathStack;
代码示例来源:origin: apache/ignite
for (int i = delimQueue.size() - 1; i >= 0; i--) {
Delimiter prevDelim = delimQueue.get(i);
delimQueue.removeAll(delimQueue.subList(replaceIdx, delimQueue.size()));
delimQueue.add(newDelim);
Delimiter delim = delimQueue.get(0);
代码示例来源:origin: apache/activemq
/**
* Get the BitArray for the index
*
* @param index
* @return BitArray
*/
private BitArray getBitArray(long index) {
int bin = getBin(index);
BitArray answer = null;
if (bin >= 0) {
if (bin >= maxNumberOfArrays) {
int overShoot = bin - maxNumberOfArrays + 1;
while (overShoot > 0) {
list.removeFirst();
longFirstIndex += BitArray.LONG_SIZE;
list.add(new BitArray());
overShoot--;
}
bin = maxNumberOfArrays - 1;
}
answer = list.get(bin);
if (answer == null) {
answer = new BitArray();
list.set(bin, answer);
}
}
return answer;
}
代码示例来源:origin: stanfordnlp/CoreNLP
isNewlineQueue.add(cp == '\n');
if (nextOffset < origText.length()) {
int nextCodePoint = origText.codePointAt(nextOffset);
isNewlineQueue.add(nextCodePoint == '\n');
} else {
isNewlineQueue.add(false);
boolean prevIsNewline = isNewlineQueue.get(0);
boolean currIsNewline = isNewlineQueue.get(1);
boolean nextIsNewline = isNewlineQueue.get(2);
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testInClauseParameterPadding() {
sqlStatementInterceptor.clear();
doInJPA( this::entityManagerFactory, entityManager -> {
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> query = cb.createQuery( Long.class );
Root<Document> document = query.from( Document.class );
ParameterExpression<List> inClauseParams = cb.parameter( List.class, "ids" );
query
.select( document.get( "id" ) )
.where(
document.get( "id" ).in( inClauseParams )
);
List<Long> ids = entityManager.createQuery( query )
.setParameter(
"ids",
Arrays.asList(
1,
2,
3,
4,
5
)
)
.getResultList();
assertEquals( 1, ids.size() );
} );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).endsWith( "in (? , ? , ? , ? , ? , ? , ? , ?)" ) );
}
代码示例来源:origin: hibernate/hibernate-orm
@Test
public void testStoredProcedureOutParameter() throws SQLException {
clearSpies();
doInHibernate( this::sessionFactory, session -> {
Person person = new Person();
person.id = 1L;
person.name = "Vlad Mihalcea";
session.persist( person );
} );
assertEquals( 1, sqlStatementInterceptor.getSqlQueries().size() );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().startsWith( "insert into" ) );
Connection connectionSpy = connectionProvider.getConnectionSpyMap().keySet().iterator().next();
verify( connectionSpy, times(1) ).setTransactionIsolation( Connection.TRANSACTION_REPEATABLE_READ );
clearSpies();
doInHibernate( this::sessionFactory, session -> {
Person person = session.find( Person.class, 1L );
assertEquals( "Vlad Mihalcea", person.name );
} );
assertEquals( 1, sqlStatementInterceptor.getSqlQueries().size() );
assertTrue( sqlStatementInterceptor.getSqlQueries().get( 0 ).toLowerCase().startsWith( "select" ) );
connectionSpy = connectionProvider.getConnectionSpyMap().keySet().iterator().next();
verify( connectionSpy, times(1) ).setTransactionIsolation( Connection.TRANSACTION_REPEATABLE_READ );
}
代码示例来源:origin: nutzam/nutz
/**
* 访问头部开始第几个字节, 不删除
* @param index
* @return 头部的第N个字符
* @throws IOException
*/
public int peek(int index) throws IOException{
while(cache.size() <= index){
cache.add(is.read());
}
return cache.get(index);
}
内容来源于网络,如有侵权,请联系作者删除!