本文整理汇总了Java中java.util.Deque.size方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.size方法的具体用法?Java Deque.size怎么用?Java Deque.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readAttribute
import java.util.Deque; //导入方法依赖的package包/类
@Override
public String readAttribute(final HttpServerExchange exchange) {
Deque<String> res = exchange.getPathParameters().get(parameter);
if(res == null) {
return null;
}else if(res.isEmpty()) {
return "";
} else if(res.size() ==1) {
return res.getFirst();
} else {
StringBuilder sb = new StringBuilder("[");
int i = 0;
for(String s : res) {
sb.append(s);
if(++i != res.size()) {
sb.append(", ");
}
}
sb.append("]");
return sb.toString();
}
}
示例2: setupStepReturnPredicateBreak
import java.util.Deque; //导入方法依赖的package包/类
protected void setupStepReturnPredicateBreak() {
final IExecutionEngine seqEngine = (IExecutionEngine) engine;
final Deque<MSEOccurrence> stack = seqEngine.getCurrentStack();
if (stack.size() > 1) {
final Iterator<MSEOccurrence> it = stack.iterator();
it.next();
addPredicateBreak(new BiPredicate<IExecutionEngine, MSEOccurrence>() {
// The operation we want to step return
private MSEOccurrence steppedReturn = it.next();
@Override
public boolean test(IExecutionEngine t, MSEOccurrence u) {
// We finished stepping over once the mseoccurrence is not
// there anymore
return !seqEngine.getCurrentStack().contains(steppedReturn);
}
});
}
}
示例3: main
import java.util.Deque; //导入方法依赖的package包/类
public static void main(String[] args) {
Scanner scann = new Scanner(System.in);
Deque<String> names = new ArrayDeque<>();
Collections.addAll(names, scann.nextLine().split("\\s+"));
int count = Integer.parseInt(scann.nextLine());
while (names.size() > 1){
for (int i = 1; i < count; i++) {
names.add(names.poll());
}
System.out.println("Removed " + names.poll());
}
System.out.println("Last is " + names.poll());
}
示例4: sortElementTopologically
import java.util.Deque; //导入方法依赖的package包/类
private List<TypeElement> sortElementTopologically(Map<TypeElement, Set<TypeElement>> dependencies) {
List<TypeElement> elements = new ArrayList<>();
Set<TypeElement> visited = new HashSet<>();
Deque<TypeElement> stack = new ArrayDeque<>();
for (Map.Entry<TypeElement, Set<TypeElement>> entry : dependencies.entrySet()) {
if (!visited.contains(entry.getKey())) {
exploreChildrenDFS(dependencies, entry.getKey(), stack, visited);
}
}
while (stack.size() > 0) {
elements.add(stack.removeLast());
}
return elements;
}
示例5: call
import java.util.Deque; //导入方法依赖的package包/类
public Subscriber<? super T> call(Subscriber<? super T> subscriber) {
final Deque<Object> deque = new ArrayDeque();
final NotificationLite<T> notification = NotificationLite.instance();
final TakeLastQueueProducer<T> producer = new TakeLastQueueProducer(notification, deque, subscriber);
subscriber.setProducer(producer);
final Subscriber<? super T> subscriber2 = subscriber;
return new Subscriber<T>(subscriber) {
public void onStart() {
request(Long.MAX_VALUE);
}
public void onCompleted() {
deque.offer(notification.completed());
producer.startEmitting();
}
public void onError(Throwable e) {
deque.clear();
subscriber2.onError(e);
}
public void onNext(T value) {
if (OperatorTakeLast.this.count != 0) {
if (deque.size() == OperatorTakeLast.this.count) {
deque.removeFirst();
}
deque.offerLast(notification.next(value));
}
}
};
}
示例6: getSignificantIncommingString
import java.util.Deque; //导入方法依赖的package包/类
public static String getSignificantIncommingString(Instance in) {
Set<Instance> processed = new HashSet<Instance>();
String temp = null;
Deque<Instance> fifo = new ArrayDeque<Instance>();
fifo.add(in);
while (!fifo.isEmpty()) {
if (fifo.size() > 10) {
Logger.getLogger(Utils.class.getName()).log(Level.FINE, "overflow in getSignificantIncommingString({0})", new Object[] { in });
break;
}
Instance act = fifo.removeFirst();
@SuppressWarnings("unchecked")
List<Value> incoming = act.getReferences();
for (Value v : incoming) {
String rName = v.getDefiningInstance().getJavaClass().getName();
if (temp == null) {
temp = "<< " + rName; // there is at least some incoming ref
}
if (rName.startsWith("java.") || rName.startsWith("javax.")) { // NOI18N
Instance i = v.getDefiningInstance();
if (processed.add(i)) {
fifo.add(i);
}
} else { // Bingo!
return rName;
}
}
}
return (temp == null) ? "unknown" : temp; // NOI18N
}
示例7: updateRegionLoad
import java.util.Deque; //导入方法依赖的package包/类
/**
* Store the current region loads.
*/
private synchronized void updateRegionLoad() {
// We create a new hashmap so that regions that are no longer there are removed.
// However we temporarily need the old loads so we can use them to keep the rolling average.
Map<String, Deque<RegionLoad>> oldLoads = loads;
loads = new HashMap<String, Deque<RegionLoad>>();
for (ServerName sn : clusterStatus.getServers()) {
ServerLoad sl = clusterStatus.getLoad(sn);
if (sl == null) {
continue;
}
for (Entry<byte[], RegionLoad> entry : sl.getRegionsLoad().entrySet()) {
Deque<RegionLoad> rLoads = oldLoads.get(Bytes.toString(entry.getKey()));
if (rLoads == null) {
// There was nothing there
rLoads = new ArrayDeque<RegionLoad>();
} else if (rLoads.size() >= numRegionLoadsToRemember) {
rLoads.remove();
}
rLoads.add(entry.getValue());
loads.put(Bytes.toString(entry.getKey()), rLoads);
}
}
for(CostFromRegionLoadFunction cost : regionLoadFunctions) {
cost.setLoads(loads);
}
}
示例8: checkConjestion
import java.util.Deque; //导入方法依赖的package包/类
/**
* 检查路书中是否含有拥堵路段,所有拥堵路段都必须大于150米
*
* @param conditionDistances
* @return
*/
private boolean checkConjestion(Deque<FormatTrafficNode> conditionDistances) {
int l = conditionDistances.size();
if (l == 0)
return false;
FormatTrafficNode t;
while ((t = conditionDistances.poll()) != null) {
if (t.getDistance() > 150) {
return true;
}
conditionDistances.poll();
}
return false;
}
示例9: formatConjestionDistance
import java.util.Deque; //导入方法依赖的package包/类
private Deque<Integer> formatConjestionDistance(List<RoadConditionItem> conditionItems, int eIndex, double totalDistance) {
Deque<Integer> dists = new ArrayDeque<Integer>();
RoadConditionItem item;
int t;
double maxIndex = conditionItems.get(conditionItems.size() - 1).curItemEndIndex;
for (RoadConditionItem conditionItem : conditionItems) {
conditionItem.curItemEndIndex = (int) (conditionItem.curItemEndIndex / maxIndex * totalDistance);
}
for (int i = 0; i < eIndex; i++) {
item = conditionItems.get(i);
if (dists.size() == 0) {
if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
dists.offer(i == 0 ? item.curItemEndIndex : item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex);
}
} else {
t = dists.size();
if ((t & 1) == 1) {//奇数,拥堵长度
if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
} else {
dists.offer((item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
}
} else {//偶数,顺畅长度
if (item.roadConditionType > RoadConditionItem.ROAD_CONDITION_TYPE_Straightway) {
if (dists.getLast() <= 100) {
dists.pollLast();
dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
} else {
dists.offer((item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
}
} else {
dists.offer(dists.pollLast() + (item.curItemEndIndex - conditionItems.get(i - 1).curItemEndIndex));
}
}
}
}
return dists;
}
示例10: run
import java.util.Deque; //导入方法依赖的package包/类
public void run(Deque<Integer> deq) {
while (deq.size() > 1) {
Iterator<Integer> it = deq.iterator();
it.next(); it.remove();
it = deq.descendingIterator();
it.next(); it.remove();
}
System.out.println(deq);
}
示例11: pop
import java.util.Deque; //导入方法依赖的package包/类
private void pop(Call callType, boolean suppressFinish)
{
Deque<Frame> ourStack = ThreadInfo.getStack();
if (!ourStack.isEmpty())
{
Frame frame = ourStack.peek();
if ((frame.callType == callType) ||
(frame.callType == Call.AVAILABLE_AND_TRANSFORM && callType == Call.AVAILABLE))
{
int size = ourStack.size();
String ms = ms(System.currentTimeMillis() - frame.start);
logInfo(frame, size, ms);
boolean firstLevel = size == 1;
if (!suppressFinish && (firstLevel || logger.isTraceEnabled()))
{
log(FINISHED_IN + ms +
(frame.callType == Call.AVAILABLE ? " Transformer NOT called" : "") +
(firstLevel ? "\n" : ""),
firstLevel);
}
setDebugOutput(frame.origDebugOutput);
ourStack.pop();
}
}
}
示例12: generatePath
import java.util.Deque; //导入方法依赖的package包/类
public Deque<DistanceFrom> generatePath() {
List<FutureTask<DistanceFrom>> effectiveDistanceFromStart = calculateDistanceFromStart(
initialPosition,
getInRange(
initialPosition,
MIN_DISTANCE_FIRST_HOP,
MAX_DISTANCE_FIRST_HOP
));
Collections.shuffle(effectiveDistanceFromStart); // Randomizing the points...
for (FutureTask<DistanceFrom> distanceFromFutureTask : effectiveDistanceFromStart) {
Deque<DistanceFrom> path = new ArrayDeque<>();
try {
DistanceFrom distance = distanceFromFutureTask.get();
Map<LatLng, Boolean> visitedTable = new HashMap<>();
visitedTable.put(distance.end, true);
path.addLast(distance);
path.addAll(pathChooser(distance,
maxDistance - (distance.distance/1000),
visitedTable,
5));
if (path.size() >= HOP_MIN_NUM) {
return path;
}
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
}
return new ArrayDeque<>();
}
示例13: release
import java.util.Deque; //导入方法依赖的package包/类
private void release(DateFormat format, Locale locale)
{
synchronized( mutex )
{
Deque<DateFormat> sp = getSubpool(locale);
if( sp.size() >= poolSizePerLocale )
{
sp.addFirst(format);
}
}
}
示例14: handleEnter
import java.util.Deque; //导入方法依赖的package包/类
public static final Map<Object,Object> handleEnter(Map<Object,Object> context,
Deque<IInterceptor> queue,
Deque<IInterceptor> stack,
List<Predicate<Map<Object,Object>>> terminators) {
//NOTE: It's assumed the queue has been null-checked by this point
while (queue.size() > 0) {
IInterceptor interceptor = queue.pollFirst();
if (interceptor == null) {
context.remove("dais.queue");
return handleLeave(context, stack);
}
stack.offerFirst(interceptor);
try {
context = IInterceptor.enter(interceptor, context);
if (context.get("error") != null) {
return handleError(context, interceptor, stack);
}
} catch (Throwable t) {
context.put("error", t);
return handleError(context, interceptor, stack);
}
if (terminators != null) {
for (Predicate p : terminators) {
if (p != null && p.test(context)) {
context.remove("dais.queue");
return handleLeave(context, stack);
}
}
}
}
return context;
}
示例15: add
import java.util.Deque; //导入方法依赖的package包/类
public void add(String name, File value, String fileName, final HeaderMap headers) {
Deque<FormValue> values = this.values.get(name);
if (values == null) {
this.values.put(name, values = new ArrayDeque<>(1));
}
values.add(new FormValueImpl(value, fileName, headers));
if (values.size() > maxValues) {
throw UndertowMessages.MESSAGES.tooManyParameters(maxValues);
}
if (++valueCount > maxValues) {
throw UndertowMessages.MESSAGES.tooManyParameters(maxValues);
}
}