java.util.LinkedList.offerLast()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(230)

本文整理了Java中java.util.LinkedList.offerLast()方法的一些代码示例,展示了LinkedList.offerLast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedList.offerLast()方法的具体详情如下:
包路径:java.util.LinkedList
类名称:LinkedList
方法名:offerLast

LinkedList.offerLast介绍

[英]Inserts the specified element at the end of this list.
[中]在此列表末尾插入指定的元素。

代码示例

代码示例来源:origin: apache/flink

splits.offerLast(split);

代码示例来源:origin: apache/flink

/**
 * Adds a single input split
 *
 * @param split The input split to add
 */
public void addInputSplit(LocatableInputSplitWithCount split) {
  int localCount = split.getLocalCount();
  if (minLocalCount == -1) {
    // first split to add
    this.minLocalCount = localCount;
    this.elementCycleCount = 1;
    this.splits.offerFirst(split);
  } else if (localCount < minLocalCount) {
    // split with new min local count
    this.nextMinLocalCount = this.minLocalCount;
    this.minLocalCount = localCount;
    // all other splits have more local host than this one
    this.elementCycleCount = 1;
    splits.offerFirst(split);
  } else if (localCount == minLocalCount ) {
    this.elementCycleCount++;
    this.splits.offerFirst(split);
  } else {
    if (localCount < nextMinLocalCount) {
      nextMinLocalCount = localCount;
    }
    splits.offerLast(split);
  }
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

@Override
public boolean offer(E e) {
  if (size() >= _capacity) {
    _linkedList.removeFirst();
  }
  _linkedList.offerLast(e);
  return true;
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Override
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
  return queue.offerLast(e);
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Override
public boolean offerLast(E e) {
  return queue.offerLast(e);
}

代码示例来源:origin: com.google.jsilver/jsilver

private void initStackAndSet() {
 objectStack = new LinkedList<T>();
 objectsSet = new HashSet<T>();
 objectStack.offerLast(firstObject);
 objectsSet.add(firstObject);
 // there is no need for using firstObject pointer anymore
 firstObject = null;
}

代码示例来源:origin: com.virjar/dungproxy-client

@Override
public boolean offerLast(T t) {
  lock.lock();
  try {
    boolean ret = super.offerLast(t);
    notifyIfNotEmpty();
    return ret;
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: org.apache.openejb.patch/openjpa-kernel

@Override
public boolean offerLast(Object paramObject) {
  if (_directAccess) {
    return super.offerLast(paramObject);
  }
  if (isDelayLoad()) {
    load();
  }
  return super.offerLast(paramObject);
}

代码示例来源:origin: org.apache.openjpa/openjpa-all

@Override
public boolean offerLast(Object paramObject) {
  if (_directAccess) {
    return super.offerLast(paramObject);
  }
  if (isDelayLoad()) {
    load();
  }
  return super.offerLast(paramObject);
}

代码示例来源:origin: org.apache.openjpa/openjpa-kernel

@Override
public boolean offerLast(Object paramObject) {
  if (_directAccess) {
    return super.offerLast(paramObject);
  }
  if (isDelayLoad()) {
    load();
  }
  return super.offerLast(paramObject);
}

代码示例来源:origin: uk.org.retep.tools/collections

@Override
public boolean offerLast( E e )
{
  if( size() >= maxElements )
  {
    return false;
  }
  return super.offerLast( e );
}

代码示例来源:origin: org.onehippo.cms7/hippo-cms7-utilities

@Override
public boolean offerLast(E element) {
  validateCapacityAndPollFirstIfNeeded();
  return super.offerLast(element);
}

代码示例来源:origin: org.apache.openejb.patch/openjpa

@Override
public boolean offerLast(Object paramObject) {
  if (_directAccess) {
    return super.offerLast(paramObject);
  }
  if (isDelayLoad()) {
    load();
  }
  return super.offerLast(paramObject);
}

代码示例来源:origin: stackoverflow.com

public class RingGroupPrint {
 public static void printSquare(int min,int max){
  LinkedList<Integer> list = new LinkedList<Integer>();
  for (int a=min; a<=max; a++) {
   list.add(a);
  }

  for (int i= 0, amount = max-min +1; i<amount; i++ ){
   for (Integer val: list) {
    System.out.print(val);
   }
   list.offerLast(list.pollFirst());
   System.out.println();
  }
 }

 public static void main(String[] args) {
  printSquare(1, 5);
 }
}

代码示例来源:origin: net.digitalid.utility/utility-collections

@Impure
@Override
@NonFrozenRecipient
public boolean offerLast(@Captured E element) {
  return super.offerLast(element);
}

代码示例来源:origin: root-wyj/springboot_im

@Override
public void addCost(long userId, int cost) {
  if (userId == context.joinedUserId.peek()) {
    if (cost < context.preRoundCost) {
      RoomContext.logger.info("{}(id:{})想加注{}。 但是小于之前{}的注码,失败!", context.usersInRoom.get(userId).getUser().getUsername(), userId, cost, context.preRoundCost);
      return;
    }
    context.usersInRoom.get(userId).addThisGameCost(cost);
    RoomContext.logger.info("{}(id:{})加注{}。",context.usersInRoom.get(userId).getUser().getUsername(), userId, cost);
    context.gameCosted += cost;
    context.preRoundCost = cost;
    Long pollId = context.joinedUserId.pollFirst();
    context.joinedUserId.offerLast(pollId);
  } else {
    RoomContext.logger.info("{}(id:{})想加注{}, 但是还没轮到他说话。",context.usersInRoom.get(userId).getUser().getUsername(), userId, cost);
  }
  
}

代码示例来源:origin: jsettlers/settlers-remake

private void handleBricklayerRequest() {
  BricklayerRequest bricklayerRequest = bricklayerRequests.poll();
  if (bricklayerRequest != null && bricklayerRequest.isRequestAlive()) {
    IManageableBricklayer bricklayer = joblessBricklayers.removeObjectNextTo(bricklayerRequest.getPosition());
    if (bricklayer != null) {
      if (!bricklayer.setBricklayerJob(bricklayerRequest.building, bricklayerRequest.bricklayerTargetPos, bricklayerRequest.direction)) {
        bricklayerRequests.add(bricklayerRequest);
      }
    } else if (!bricklayerRequest.isCreationRequested()) { // if the creation hasn't been requested yet => request it.
      createNewToolUser(bricklayerRequest);
      bricklayerRequest.setCreationRequested();
      bricklayerRequests.offerLast(bricklayerRequest);
    } else { // no bricklayer available and creation already requested => nothing to do.
      bricklayerRequests.offerLast(bricklayerRequest);
    }
  }
}

代码示例来源:origin: jsettlers/settlers-remake

private void handleWorkerRequest() {
  WorkerRequest workerRequest = workerRequests.poll();
  if (workerRequest != null) {
    IManageableWorker worker = joblessWorkers.removeObjectNextTo(workerRequest.getPosition(), currentWorker -> currentWorker.getMovableType() == workerRequest.movableType);
    if (worker != null && worker.isAlive()) {
      worker.setWorkerJob(workerRequest.building);
    } else {
      if (!workerRequest.creationRequested) {
        workerRequest.creationRequested = true;
        createNewToolUser(workerRequest);
      }
      workerRequests.offerLast(workerRequest);
    }
  }
}

代码示例来源:origin: org.nuiton.wikitty/wikitty-api

@Override
public boolean visitEnter(TreeNodeResult<String> node) {
  String id = node.getObject();
  int count = node.getAttCount();
  
  TARGET object = converter.convert(id);
  TreeNodeResult<TARGET> newNode = new TreeNodeResult<TARGET>(
      object, count);
  TreeNodeResult<TARGET> parent = stack.peekLast();
  if (parent == null) {
    // le premier noeud, donc le root a retourner plus tard
    tree = newNode;
  } else {
    parent.add(newNode);
  }
  stack.offerLast(newNode);
  return true;
}

代码示例来源:origin: org.nuiton.wikitty/wikitty-api

@Override
public boolean visitEnter(WikittyQueryResultTreeNode<String> node) {
  String id = node.getObject();
  int count = node.getAttCount();
  
  TARGET object = converter.convert(id);
  WikittyQueryResultTreeNode<TARGET> newNode = new WikittyQueryResultTreeNode<TARGET>(
      object, count);
  WikittyQueryResultTreeNode<TARGET> parent = stack.peekLast();
  if (parent == null) {
    // le premier noeud, donc le root a retourner plus tard
    tree = newNode;
  } else {
    parent.add(newNode);
  }
  stack.offerLast(newNode);
  return true;
}

相关文章