本文整理匯總了Java中java.util.LinkedList.push方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedList.push方法的具體用法?Java LinkedList.push怎麽用?Java LinkedList.push使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.push方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: open
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* Opens a Gui to a player, adding it to the stack. If the closeOthers parameter is specified it will removeHotbar the stack first
*
* @param player the player that is opening the api
* @param gui the gui to be opened
* @param closeOthers if give to true the GUI histories would be cleaned
*/
public void open(Player player, Gui gui, boolean closeOthers) {
if (called) return;
called = true;
try {
LinkedList<Gui> g = getOrCreate(player);
Gui oldGui = g.peek();
GuiOpenEvent e = new GuiOpenEvent(player, gui, oldGui);
e.setCloseOthers(closeOthers);
Bukkit.getPluginManager().callEvent(e);
if (e.isCancelled()) {
if (g.isEmpty())
histories.remove(player);
return;
}
closeOthers = e.isCloseOthers();
if (oldGui != null)
oldGui.onClose(player);
if (closeOthers)
g.clear();
gui.onOpen(player);
gui.show(player);
g.push(gui);
} finally {
called = false;
}
}
示例2: transferThroughList
import java.util.LinkedList; //導入方法依賴的package包/類
private String transferThroughList(String in, int index) {
LinkedList<String> list = new LinkedList<String>();
list.add(System.getenv("")); // taints the list
list.clear(); // makes the list safe again
list.add(1, "xx");
list.addFirst(in); // can taint the list
list.addLast("yy");
list.push(in);
return list.element() + list.get(index) + list.getFirst() + list.getLast()
+ list.peek() + list.peekFirst() + list.peekLast() + list.poll()
+ list.pollFirst() + list.pollLast() + list.pop() + list.remove()
+ list.remove(index) + list.removeFirst() + list.removeLast()
+ list.set(index, "safe") + list.toString();
}
示例3: run
import java.util.LinkedList; //導入方法依賴的package包/類
default String run( LinkedList<StackItem> items ) {
if ( items.size() < 2 ) {
return "<Not enough inputs in the stack>";
}
StackItem item2 = items.pop();
StackItem item1 = items.pop();
if ( item1 instanceof Numeric && item2 instanceof Numeric ) {
Numeric result = new Numeric( apply( ( ( Numeric ) item1 ).value, ( ( Numeric ) item2 ).value ) );
items.push( result );
return result.name();
} else {
items.push( item1 );
items.push( item2 );
return "<" + name() + " error - stack does not contain two numbers at the top>";
}
}
示例4: chooseIntentions
import java.util.LinkedList; //導入方法依賴的package包/類
private LinkedList<Action> chooseIntentions(
MentalState.Desire goal, Set<Action> actionsPossible
) {
LinkedList<Action> intentions = new LinkedList<>();
// Ramasse les bijoux avant d'aspirer
if (actionsPossible.contains(Action.GATHER_JEWELRY))
intentions.push(Action.GATHER_JEWELRY);
else if (actionsPossible.contains(Action.VACUUM_DUST))
intentions.push(Action.VACUUM_DUST);
else {
// A random move
ThreadLocalRandom random = ThreadLocalRandom.current();
int countPossibleActions = actionsPossible.size();
int actionNumber = random.nextInt(countPossibleActions);
intentions.push((Action) (actionsPossible.toArray())[actionNumber]);
}
return intentions;
}
示例5: getCollisions
import java.util.LinkedList; //導入方法依賴的package包/類
@Override
public List<RayCastResult> getCollisions( StraightLine3D ray, double minDistanceSquare, double maxDistanceSquare, ArrayList<Triangle> data ) {
LinkedList<RayCastResult> retval = new LinkedList<RayCastResult>();
// now let's examine the ray's collisions with triangles
for(Triangle triangle : data) {
SimplePlanarPolygon3D trianglePolygon = triangle.planarPolygon;
Plane3D trianglePlane = trianglePolygon.getPlane();
Double intersectionParameter = ray.getPlaneIntersectionParametric(trianglePlane);
if ( Double.isInfinite(intersectionParameter) || intersectionParameter < 0 || intersectionParameter > 1 ) {
// no intersection or intersection in wrong direction or past the point
continue;
}
Point3D intersection = ray.getPoint(intersectionParameter);
double intersectionDistanceSquare = ray.getOrigin().getDistanceSquare(intersection);
if ( intersectionDistanceSquare < minDistanceSquare || maxDistanceSquare < intersectionDistanceSquare ) {
continue;
}
Point2D intersection2D = trianglePlane.getCoordinateSubsystem().project( intersection );
SimplePolygon2D polygon2D = trianglePolygon.getPolygonIn2d();
if ( !polygon2D.contains( intersection2D, triangle.signedAreaIn2dProjection ) ) {
// intersection is outside the polygon
continue;
}
Location intersectionLocation = new Location(intersection);
retval.push( new RayCastResult( ray, intersectionLocation, trianglePlane.getNormalVector(), Math.sqrt(intersectionDistanceSquare), triangle ) );
}
Collections.sort( retval, hitDistanceComparator );
return retval;
}
示例6: createWordsPermutation
import java.util.LinkedList; //導入方法依賴的package包/類
private LinkedList<String> createWordsPermutation(List<String> words, int i, Ending ending) {
LinkedList<String> currPermutation = Lists.newLinkedList(words);
for (int k = 0; k < i; k++) {
if (ending == Ending.HEAD || ending == Ending.BOTH) {
String currHeadPwd = Strings.padEnd(HEAD_ELEMENT, i - k, HEAD_ELEMENT.charAt(0));
currPermutation.push(currHeadPwd);
}
if (ending == Ending.TAIL || ending == Ending.BOTH) {
String currTailPwd = Strings.padEnd(TAIL_ELEMENT, k, TAIL_ELEMENT.charAt(0));
currPermutation.add(currTailPwd);
}
}
return currPermutation;
}
示例7: wrapExistingMembers
import java.util.LinkedList; //導入方法依賴的package包/類
private LinkedList<RecipientWrapper> wrapExistingMembers(Collection<Recipient> recipients) {
final LinkedList<RecipientWrapper> wrapperList = new LinkedList<>();
RecipientWrapper wrapper;
for (Recipient recipient : recipients) {
wrapper = new RecipientWrapper(recipient, false, true,
isOwnerNumber(recipient.getNumber()), isAdminNumber(recipient.getNumber()));
if(Util.isOwnNumber(context, recipient.getNumber())) {
wrapperList.push(wrapper);
} else {
wrapperList.add(wrapper);
}
}
return wrapperList;
}
示例8: travelDFS
import java.util.LinkedList; //導入方法依賴的package包/類
public LinkedList<T> travelDFS(T vertex, boolean isAscending) {
LinkedList<T> results = new LinkedList<>();
HashSet<T> checkVisitSet = new HashSet<>();
LinkedList<T> stack = new LinkedList<>();
//첫 번째 Node 방문
T firstVertex = getVertex(vertex);
stack.push(firstVertex);
checkVisitSet.add(firstVertex);
while(!stack.isEmpty()) {
T poppedVertex = stack.pop();
results.add(poppedVertex);
sort(edgesByVertices.get(poppedVertex), !isAscending);
for(Edge edge : edgesByVertices.get(poppedVertex)) {
T linkedVertex = edge.getToVertex();
if(!checkVisitSet.contains(linkedVertex)) {
checkVisitSet.add(linkedVertex);
stack.push(linkedVertex);
}
}
}
return results;
}
示例9: select
import java.util.LinkedList; //導入方法依賴的package包/類
@Override
public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
try {
LinkedList<TransactionOutput> gathered = Lists.newLinkedList();
Coin valueGathered = Coin.ZERO;
for (TransactionOutput output : candidates) {
if (ignorePending && !isConfirmed(output))
continue;
// Find the key that controls output, assuming it's a regular pay-to-pubkey or pay-to-address output.
// We ignore any other kind of exotic output on the assumption we can't spend it ourselves.
final Script scriptPubKey = output.getScriptPubKey();
ECKey controllingKey;
if (scriptPubKey.isSentToRawPubKey()) {
controllingKey = wallet.findKeyFromPubKey(scriptPubKey.getPubKey());
} else if (scriptPubKey.isSentToAddress()) {
controllingKey = wallet.findKeyFromPubHash(scriptPubKey.getPubKeyHash());
} else {
log.info("Skipping tx output {} because it's not of simple form.", output);
continue;
}
checkNotNull(controllingKey, "Coin selector given output as candidate for which we lack the key");
if (controllingKey.getCreationTimeSeconds() >= unixTimeSeconds) continue;
// It's older than the cutoff time so select.
valueGathered = valueGathered.add(output.getValue());
gathered.push(output);
if (gathered.size() >= MAX_SIMULTANEOUS_INPUTS) {
log.warn("Reached {} inputs, going further would yield a tx that is too large, stopping here.", gathered.size());
break;
}
}
return new CoinSelection(valueGathered, gathered);
} catch (ScriptException e) {
throw new RuntimeException(e); // We should never have problems understanding scripts in our wallet.
}
}
示例10: push
import java.util.LinkedList; //導入方法依賴的package包/類
public void push(Object v) {
LinkedList lastStack = getLastStack();
if (lastStack != null && lastStack.size() != capacity) {
lastStack.push(v);
} else {
LinkedList newStack = new LinkedList();
newStack.push(v);
stacks.add(newStack);
}
}
示例11: handleObjectAnnotation
import java.util.LinkedList; //導入方法依賴的package包/類
/*******************
* Handle an objectAnnotation element, extracting the object endpoint
* details if found.
*
* @param obj The RMIObject to populate with class names.
* @param dataStack The remaining data in the ReplyData packet.
******************/
private void handleObjectAnnotation(RMIObject obj, LinkedList<Byte> dataStack) throws BaRMIeInvalidReplyDataPacketException {
byte b;
//Read elements from the stream until a TC_ENDBLOCKDATA element is read
while((b = dataStack.pop()) != ObjectStreamConstants.TC_ENDBLOCKDATA) {
//Handle the annotation
switch(b) {
//Look for object endpoint details in block data elements
case ObjectStreamConstants.TC_BLOCKDATA:
//Push the block type back on to the stack and extract endpoint details if found
dataStack.push(ObjectStreamConstants.TC_BLOCKDATA);
this.extractObjectEndpointFromBlockData(obj, dataStack);
break;
//Skip over object annotations
case ObjectStreamConstants.TC_OBJECT:
this.handleNewObjectElement(obj, dataStack);
break;
//Ignore null annotations...
case ObjectStreamConstants.TC_NULL:
break;
//Unknown annotation type
default:
throw new BaRMIeInvalidReplyDataPacketException("Unknown classAnnotation element type (0x" + String.format("%02x", b) + ").");
}
}
}
示例12: equateIntervals
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* computes whether the test interval list is equivalent to master. To be equivalent, test must
* contain GenomeLocs covering every base in master, exactly once. Note that this algorithm
* assumes that master genomelocs are all discontiguous (i.e., we don't have locs like 1-3 and 4-6 but
* rather just 1-6). In order to use this algorithm with contiguous genomelocs first merge them. The algorithm
* doesn't assume that test has discontinuous genomelocs.
*
* Returns a null string if there are no differences, otherwise returns a string describing the difference
* (useful for UnitTests). Assumes both lists are sorted
*
* @param masterArg sorted master genome locs
* @param testArg sorted test genome locs
* @return null string if there are no difference, otherwise a string describing the difference
*/
public static String equateIntervals(List<GenomeLoc> masterArg, List<GenomeLoc> testArg) {
LinkedList<GenomeLoc> master = new LinkedList<GenomeLoc>(masterArg);
LinkedList<GenomeLoc> test = new LinkedList<GenomeLoc>(testArg);
while ( ! master.isEmpty() ) { // there's still unchecked bases in master
final GenomeLoc masterHead = master.pop();
final GenomeLoc testHead = test.pop();
if ( testHead.overlapsP(masterHead) ) {
// remove the parts of test that overlap master, and push the remaining
// parts onto master for further comparison.
for ( final GenomeLoc masterPart : Utils.reverse(masterHead.subtract(testHead)) ) {
master.push(masterPart);
}
} else {
// testHead is incompatible with masterHead, so we must have extra bases in testHead
// that aren't in master
return "Incompatible locs detected masterHead=" + masterHead + ", testHead=" + testHead;
}
}
if ( test.isEmpty() ) // everything is equal
return null; // no differences
else
return "Remaining elements found in test: first=" + test.peek();
}
示例13: setCurrentHelper
import java.util.LinkedList; //導入方法依賴的package包/類
protected void setCurrentHelper(OnlineSectioningHelper helper) {
LinkedList<OnlineSectioningHelper> h = sHelper.get();
if (h == null) {
h = new LinkedList<OnlineSectioningHelper>();
sHelper.set(h);
}
h.push(helper);
}
示例14: bubbleUpNodeTable
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* Propagates node table of given DAG to all of it ancestors.
*/
private void bubbleUpNodeTable(DAGraph<DataT, NodeT> from, LinkedList<String> path) {
if (path.contains(from.rootNode.key())) {
path.push(from.rootNode.key()); // For better error message
throw new IllegalStateException("Detected circular dependency: " + StringUtils.join(path, " -> "));
}
path.push(from.rootNode.key());
for (DAGraph<DataT, NodeT> to : from.parentDAGs) {
this.merge(from.nodeTable, to.nodeTable);
this.bubbleUpNodeTable(to, path);
}
path.pop();
}
示例15: addFieldToStack
import java.util.LinkedList; //導入方法依賴的package包/類
private static void addFieldToStack(String prefix, Object val, LinkedList<Map<String, Object>> stack,
List<Map<String, Object>> keysAndValues) {
if (val instanceof Map) {
// flatten all nested objects
stack.push(Collections.singletonMap(prefix, val));
} else if (val instanceof List) {
// input array: key: [value1, value2] - [{k: key-0, v: value1}, {k: key-1, v: value2}]
for (int i = 0; i < ((List) val).size(); i++) {
stack.push(Collections.singletonMap(prefix + "-" + String.valueOf(i), ((List) val).get(i)));
}
} else {
keysAndValues.add(getKeyValueField(prefix, val));
}
}