本文整理了Java中java.util.LinkedList.offer()
方法的一些代码示例,展示了LinkedList.offer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.offer()
方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:offer
[英]Adds the specified element as the tail (last element) of this list.
[中]添加指定元素作为此列表的尾部(最后一个元素)。
代码示例来源:origin: Rajawali/Rajawali
/**
* Adds a task to the frame task queue.
*
* @param task AFrameTask to be added.
* @return boolean True on successful addition to queue.
*/
private boolean internalOfferTask(AFrameTask task) {
synchronized (mFrameTaskQueue) {
return mFrameTaskQueue.offer(task);
}
}
代码示例来源:origin: killme2008/Metamorphosis
@Override
protected void subAppend(LoggingEvent event) {
synchronized (this.events) {
while (this.events.size() >= this.logBufferSize) {
this.events.poll();
}
this.events.offer(event);
}
super.subAppend(event);
}
代码示例来源:origin: crossoverJie/JCSprout
queue.offer(node) ;
BinaryNodeTravel current ;
while (!queue.isEmpty()){
queue.offer(current.getLeft()) ;
queue.offer(current.getRight()) ;
代码示例来源:origin: Clans/FloatingActionButton
private void increaseProgress(final FloatingActionButton fab, int i) {
if (i <= mMaxProgress) {
fab.setProgress(i, false);
final int progress = ++i;
mUiHandler.postDelayed(new Runnable() {
@Override
public void run() {
increaseProgress(fab, progress);
}
}, 30);
} else {
mUiHandler.postDelayed(new Runnable() {
@Override
public void run() {
fab.hideProgress();
}
}, 200);
mProgressTypes.offer(ProgressType.PROGRESS_NO_ANIMATION);
}
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected XMLEvent internalNextEvent() throws XMLStreamException {
//If there is an iterator to read from reset was called, use the iterator
//until it runs out of events.
if (this.bufferReader != null) {
final XMLEvent event = this.bufferReader.next();
//If nothing left in the iterator, remove the reference and fall through to direct reading
if (!this.bufferReader.hasNext()) {
this.bufferReader = null;
}
return event;
}
//Get the next event from the underlying reader
final XMLEvent event = this.getParent().nextEvent();
//if buffering add the event
if (this.eventLimit != 0) {
this.eventBuffer.offer(event);
//If limited buffer size and buffer is too big trim the buffer.
if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) {
this.eventBuffer.poll();
}
}
return event;
}
代码示例来源:origin: hibernate/hibernate-orm
@Override
protected XMLEvent internalNextEvent() throws XMLStreamException {
//If there is an iterator to read from reset was called, use the iterator
//until it runs out of events.
if (this.bufferReader != null) {
final XMLEvent event = this.bufferReader.next();
//If nothing left in the iterator, remove the reference and fall through to direct reading
if (!this.bufferReader.hasNext()) {
this.bufferReader = null;
}
return event;
}
//Get the next event from the underlying reader
final XMLEvent event = this.getParent().nextEvent();
//if buffering add the event
if (this.eventLimit != 0) {
this.eventBuffer.offer(event);
//If limited buffer size and buffer is too big trim the buffer.
if (this.eventLimit > 0 && this.eventBuffer.size() > this.eventLimit) {
this.eventBuffer.poll();
}
}
return event;
}
代码示例来源:origin: FudanNLP/fnlp
if(entityp.equals(entityc)){
entitycinps.add(entityp);
entityCstmp.offer(entitycs.poll());
break;
}else if(entityp.getStartIndex() == entityc.getStartIndex()){
entityCstmp.offer(entitycs.poll());
break;
entityCstmp.offer(entitycs.poll());
}else{
break;
entitycs.offer(entityp);
代码示例来源:origin: hibernate/hibernate-orm
public void addWorkUnit(AuditWorkUnit vwu) {
if ( vwu.containsWork() ) {
final Object entityId = vwu.getEntityId();
if ( entityId == null ) {
// Just adding the work unit - it's not associated with any persistent entity.
workUnits.offer( vwu );
}
else {
final String entityName = vwu.getEntityName();
final Pair<String, Object> usedIdsKey = Pair.make( entityName, entityId );
if ( usedIds.containsKey( usedIdsKey ) ) {
final AuditWorkUnit other = usedIds.get( usedIdsKey );
final AuditWorkUnit result = vwu.dispatch( other );
if ( result != other ) {
removeWorkUnit( other );
if ( result != null ) {
usedIds.put( usedIdsKey, result );
workUnits.offer( result );
}
// else: a null result means that no work unit should be kept
}
// else: the result is the same as the work unit already added. No need to do anything.
}
else {
usedIds.put( usedIdsKey, vwu );
workUnits.offer( vwu );
}
}
}
}
代码示例来源:origin: Clans/FloatingActionButton
fab.setShowProgressBackground(true);
fab.setIndeterminate(true);
mProgressTypes.offer(ProgressType.INDETERMINATE);
break;
case PROGRESS_POSITIVE:
fab.setIndeterminate(false);
fab.setProgress(70, true);
mProgressTypes.offer(ProgressType.PROGRESS_POSITIVE);
break;
case PROGRESS_NEGATIVE:
fab.setProgress(30, true);
mProgressTypes.offer(ProgressType.PROGRESS_NEGATIVE);
break;
case HIDDEN:
fab.hideProgress();
mProgressTypes.offer(ProgressType.HIDDEN);
break;
case PROGRESS_NO_ANIMATION:
fab.setShowProgressBackground(false);
fab.setIndeterminate(true);
mProgressTypes.offer(ProgressType.PROGRESS_NO_BACKGROUND);
break;
代码示例来源:origin: stackoverflow.com
inQueue.offer(next);
if (next == -1)
break;
outQueue.offer((int) b);
} else
outQueue.add(inQueue.remove());
代码示例来源:origin: Clans/FloatingActionButton
mProgressTypes = new LinkedList<>();
for (ProgressType type : ProgressType.values()) {
mProgressTypes.offer(type);
代码示例来源:origin: kaaproject/kaa
GenericRecord newRecord = (GenericRecord) newValue;
if (oldRecord.getSchema().getFullName().equals(newRecord.getSchema().getFullName())) {
nextRecords.offer(new RecordTuple(oldRecord, newRecord));
} else {
hasDifferences = true;
GenericFixed newUuid = (GenericFixed) newItemRecord.get(UUID_FIELD);
if (uuid.equals(newUuid)) {
nextRecords.offer(new RecordTuple(oldItemRecord, newItemRecord));
isRecordExists = true;
break;
代码示例来源:origin: i2p/i2p.i2p
/**
* Use if it includes a link.
* Does not escape '<' and '>' before queueing
*
* @return the message id
*/
public synchronized int addMessageNoEscape(String message) {
_messages.offer(new Message(_count++, message));
while (_messages.size() > _maxSize) {
_messages.poll();
}
return _count;
}
代码示例来源:origin: zstackio/zstack
@AsyncThread
private void runQueue() {
ChainFuture cf;
synchronized (chainTasks) {
// remove from pending queue and add to running queue later
cf = (ChainFuture) pendingQueue.poll();
if (cf == null) {
if (counter.decrementAndGet() == 0) {
chainTasks.remove(syncSignature);
}
return;
}
}
synchronized (runningQueue) {
cf.startExecutionTimeInMills = System.currentTimeMillis();
// add to running queue
logger.debug(String.format("Start executing runningQueue: %s, task name: %s", syncSignature, cf.getTask().getName()));
runningQueue.offer(cf);
}
cf.run(() -> {
synchronized (runningQueue) {
runningQueue.remove(cf);
logger.debug(String.format("Finish executing runningQueue: %s, task name: %s", syncSignature, cf.getTask().getName()));
}
runQueue();
});
}
代码示例来源:origin: zstackio/zstack
void addTask(ChainFuture task) {
pendingQueue.offer(task);
if (maxThreadNum == -1) {
maxThreadNum = task.getSyncLevel();
} else if (maxThreadNum < task.getSyncLevel()) {
logger.warn(String.format("task[name:%s] increases queue[name:%s]'s sync level from %s to %s", task.getTask().getName(), task.getSyncSignature(), maxThreadNum, task.getSyncLevel()));
maxThreadNum = task.getSyncLevel();
}
if (syncSignature == null) {
syncSignature = task.getSyncSignature();
}
}
代码示例来源:origin: pondurii/vrVideo
/**
* Adds a task to the frame task queue.
*
* @param task AFrameTask to be added.
* @return boolean True on successful addition to queue.
*/
private boolean internalOfferTask(AFrameTask task) {
synchronized (mFrameTaskQueue) {
return mFrameTaskQueue.offer(task);
}
}
代码示例来源:origin: com.aol.cyclops/cyclops-streams
private T handleLeader() {
T next = it.next();
buffer.offer(next);
return next;
}
代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac
public boolean offer(Env<AttrContext> e) {
if (fileContents.offer(e)) {
contents.add(e);
return true;
}
return false;
}
代码示例来源:origin: com.toomuchcoding.jsonassert/jsonassert
@Override
public JsonVerifiable elementWithIndex(int index) {
ArrayAssertion asserter = new ArrayAssertion(parsedJson, jsonPathBuffer, jsonAsserterConfiguration);
asserter.jsonPathBuffer.offer("[" + index + "]");
return asserter;
}
代码示例来源:origin: Microsoft/botbuilder-java
private void LogActivity(Activity activity) {
synchronized (transcript) {
if (activity.timestamp() == null) {
activity.withTimestamp(DateTime.now(DateTimeZone.UTC));
}
transcript.offer(activity);
}
}
内容来源于网络,如有侵权,请联系作者删除!