List of usage examples for java.util LinkedList contains
public boolean contains(Object o)
From source file:org.eclipse.gyrex.jobs.internal.schedules.ScheduleImpl.java
public static void checkExecutionSequenceForLoops(final IScheduleEntry entry, final LinkedList<String> executionSequence, final Collection<String> precedingEntries) throws IllegalArgumentException { for (final String precedingEntryId : precedingEntries) { if (executionSequence.contains(precedingEntryId)) throw new IllegalArgumentException(String.format( "Found loop in schedule %s for preceding entry %s of entry %s in execution sequence %s.", entry.getSchedule().getId(), precedingEntryId, entry.getId(), StringUtils.join(executionSequence.descendingIterator(), "->"))); else {/*from w ww . j a v a2 s .co m*/ // no loop, add to sequence and continue check with the entry executionSequence.add(precedingEntryId); final ScheduleEntryImpl precedingEntry = ((ScheduleImpl) entry.getSchedule()) .getEntry(precedingEntryId); checkExecutionSequenceForLoops(precedingEntry, executionSequence, precedingEntry.getPrecedingEntries()); } } }
From source file:jp.co.ctc_g.jse.vid.ViewId.java
private static void is(ViewId self, ViewIdStore store) { Args.checkNotNull(self);// ww w . j a va 2 s .co m self.freeze(); synchronized (store.semaphore()) { LinkedList<ViewId> ids = store.find(); assert ids != null; if (ids.contains(self)) { int index = ids.indexOf(self); for (int i = ids.size() - 1; i > index; i--) { ids.remove(i); } if (OVERRIDE_THE_SAME_ONE) { ids.set(index, self); } } else { ids.add(self); } store.store(ids); } }
From source file:util.allocation.java
public static boolean VMIDInSeparationPolicy(HashMap<String, LinkedList<String>> finalDeploySolution, String currentHOSTSolutionID, String currentVMID, LinkedList<LinkedList<LinkedList<String>>> concreteSeparationPolicy) { LinkedList<String> VMDeployListForOneHost = finalDeploySolution.get(currentHOSTSolutionID); if (VMDeployListForOneHost != null) { for (LinkedList item : concreteSeparationPolicy) { LinkedList<String> conflictSet1 = (LinkedList<String>) item.get(0); LinkedList<String> conflictSet2 = (LinkedList<String>) item.get(1); /*/*from ww w . j a va 2 s.c o m*/ printInfo("print Conflict set"); printLinkedList(conflictSet1); printInfo("\n"); printLinkedList(conflictSet2); printInfo("\n"); printLinkedList(VMDeployListForOneHost); */ if (twoLinkedListShareSameEntity(conflictSet1, VMDeployListForOneHost) && conflictSet2.contains(currentVMID)) return true; if (twoLinkedListShareSameEntity(conflictSet2, VMDeployListForOneHost) && conflictSet1.contains(currentVMID)) return true; } return false; } else { return false; } }
From source file:de._13ducks.cor.game.server.movement.SectorPathfinder.java
/** * Der Start und Zielknoten sind von weit mehr als nur den Knoten ihres Polygons erreichbar. * Dies muss bereits whrend der Basic-Berechnung beachtet werden, das kann die Pfadoptimierung nachtrglich nichtmehr leisten. * Also alle Nodes suchen, die ohne Hinderniss direkt erreichbar sind * @param from alle vollstndig im Mesh liegenden Kanten von hier zu Nachbarknoten suchen * @param basicPolygon Der Polygon, in dem der Node drinliegt. * @return alle direkt erreichbaren Knoten (natrlich sind die des basicPolygons auch dabei) */// w ww . j a v a 2 s . c o m private static Node[] computeDirectReachable(Node from, FreePolygon basicPolygon) { // Das ist eine modifizierte Breitensuche: LinkedList<FreePolygon> open = new LinkedList<FreePolygon>(); // Queue fr zu untersuchende Polygone LinkedHashSet<FreePolygon> openContains = new LinkedHashSet<FreePolygon>(); // Welche Elemente die open enthlt (schnellerer Test) LinkedHashSet<FreePolygon> closed = new LinkedHashSet<FreePolygon>(); LinkedHashSet<Node> testedNodes = new LinkedHashSet<Node>(); LinkedList<Node> result = new LinkedList<Node>(); open.offer(basicPolygon); // Start-Polygon openContains.add(basicPolygon); while (!open.isEmpty()) { // Diesen hier bearbeiten wir jetzt FreePolygon poly = open.poll(); openContains.remove(poly); closed.add(poly); boolean containsreachableNodes = false; // Alle Nodes dieses Knotens untersuchen for (Node node : poly.getNodes()) { // Schon bekannt? if (result.contains(node)) { // Bekannt und ok containsreachableNodes = true; } else { if (testedNodes.contains(node)) { // Der geht nicht } else { // Testen! FreePolygon currentPoly = basicPolygon; // Testweise Kante zwischen from und node erstellen Edge edge = new Edge(from, node); // Im Folgenden wird untersucht, ob der neue Weg "edge" passierbar ist. // Damit wir beim Dreieckwechsel nicht wieder zurck gehen: Node lastNode = null; boolean routeAllowed = true; // Jetzt so lange weiter laufen, bis wir im Ziel-Polygon sind while (!node.getPolygons().contains(currentPoly)) { // Untersuchen, ob es eine Seite des currentPolygons gibt, die sich mit der alternativRoute schneidet List<Edge> edges = currentPoly.calcEdges(); Edge intersecting = null; SimplePosition intersection = null; for (Edge testedge : edges) { // Gibts da einen Schnitt? intersection = edge.intersectionWithEndsNotAllowed(testedge); if (intersection != null && !intersection.equals(lastNode)) { intersecting = testedge; break; } } // Kandidat fr den nchsten Polygon FreePolygon nextPoly = null; // Kante gefunden if (intersecting != null) { // Von dieser Kante die Enden suchen nextPoly = getOtherPoly(intersecting.getStart(), intersecting.getEnd(), currentPoly); } if (intersecting != null && nextPoly != null) { // Wir haben einen Schnittpunkt und eine Kante gefunden, sind jetzt also in einem neuen Polygon // Extra Node bentigt Node extraNode = intersection.toNode(); extraNode.addPolygon(nextPoly); extraNode.addPolygon(currentPoly); lastNode = extraNode; currentPoly = nextPoly; // Der nchste Schleifendurchlauf wird den nchsten Polygon untersuchen } else { // Es gab leider keinen betretbaren Polygon hier. // Das bedeutet, dass wir die Suche abbrechen knnen, es gibt hier keinen direkten Weg routeAllowed = false; break; } } // Wenn der neue Weg gltig war, einbauen. Sonst weiter mit dem nchsten Knoten if (routeAllowed) { // In die erlaubt-Liste: result.add(node); testedNodes.add(node); containsreachableNodes = true; } else { testedNodes.add(node); } } } } // Nur weiter in die Tiefe gehen, wenn mindestens einer erreichbar war if (containsreachableNodes) { // Alle Nachbarn untersuchen: for (FreePolygon n : poly.getNeighbors()) { // Schon bekannt/bearbeitet? if (!openContains.contains(n) && !closed.contains(n)) { // Nein, also auch zur Bearbeitung vorsehen open.add(n); openContains.add(n); } } } } return result.toArray(new Node[0]); }
From source file:util.allocation.java
public static HashMap<String, LinkedList<String>> generateFinalDeploySolution(AbstractOrbacPolicy p, LinkedList<VM> VMList, LinkedList<HOST> HOSTList, LinkedList<LinkedList<LinkedList<String>>> concreteSeparationPolicy) throws COrbacException { HashMap<String, LinkedList<String>> finalDeploySolution = new HashMap<String, LinkedList<String>>(); LinkedList<String> VMAlreadyAllocateList = new LinkedList<String>(); Set concretePermissionList = p.GetConcretePermissions(); Iterator iter = concretePermissionList.iterator(); while (iter.hasNext()) { CConcretePermission Cpermission = (CConcretePermission) iter.next(); String currentVMID = Cpermission.GetObject(); //System.out.println("Preempted"+Cpermission.GetName()); if ((Cpermission.IsPreempted() == null) && !(VMAlreadyAllocateList.contains(currentVMID))) { VM currentVM = getVMByID(currentVMID, VMList); LinkedList<String> HOSTIDListForCurrentVMID = getAllPermitHostIDInPolicy(currentVMID, p); /* printInfo("HOSTIDListForCurrentVMID"); printLinkedList(HOSTIDListForCurrentVMID);*/ HOSTIDListForCurrentVMID = rankingHostlistFromCheapToHighAndReturnHOSTIDList( HOSTIDListForCurrentVMID, HOSTList); for (String currentHOSTSolutionID : HOSTIDListForCurrentVMID) {/* w w w . jav a 2s .c om*/ HOST currentHOST = getHOSTByID(currentHOSTSolutionID, HOSTList); if (!VMIDInSeparationPolicy(finalDeploySolution, currentHOSTSolutionID, currentVMID, concreteSeparationPolicy) && currentHOSTSatisfyCurrentVMForCapacity(currentHOST, currentVM) && !(VMAlreadyAllocateList.contains(currentVMID))) { if (finalDeploySolution.containsKey(currentHOSTSolutionID)) { LinkedList<String> currentVMSolution = finalDeploySolution.get(currentHOSTSolutionID); currentVMSolution.add(currentVMID); finalDeploySolution.replace(currentVMID, currentVMSolution); } else { LinkedList<String> currentVMSolution = new LinkedList<String>(); currentVMSolution.add(currentVMID); finalDeploySolution.put(currentHOSTSolutionID, currentVMSolution); } HOSTList = recalculateSpaceForHOSTList(HOSTList, currentHOSTSolutionID, currentVM); VMAlreadyAllocateList.add(currentVMID); } } } } /* printInfo("seperation policy"); printLinkedList(concreteSeparationPolicy); printInfo("Host list after allocation"); for (HOST eachHOST: HOSTList) { eachHOST.printInfo(); } */ return finalDeploySolution; }
From source file:io.github.jeddict.jpa.spec.extend.cache.Cache.java
public void addClass(String _class, LinkedList<String> collection) { if (StringUtils.isEmpty(_class)) { return;/*from ww w .j a v a 2 s .c o m*/ } if (collection.contains(_class)) { collection.remove(_class); } while (COLLECTION_SIZE < collection.size()) { collection.removeLast(); } collection.addFirst(_class); }
From source file:net.mindengine.blogix.web.tiles.TilesContainer.java
private void extendTile(Tile tile, TileLine lookOutsideTileLine, LinkedList<String> extensionChainList) { if (extensionChainList.contains(lookOutsideTileLine.getExtendedBaseName())) { throw new IllegalArgumentException("There is a cross reference in extension chain of tiles"); }/*from ww w .ja v a2 s . c om*/ extensionChainList.add(lookOutsideTileLine.getExtendedBaseName()); TileLine baseTileLine = findBaseTileLineFor(lookOutsideTileLine); if (baseTileLine.isExtending()) { extendTile(tile, baseTileLine, extensionChainList); } else { tile.setValue(baseTileLine.value); } if (baseTileLine.children != null) { for (TileLine childLine : baseTileLine.children) { tile.getTiles().put(childLine.key, convertTile(childLine)); } } }
From source file:jp.troter.tags.capture.ContentForTag.java
public void concatToContextValue(String name, LinkedList<String> current) { String value = StringUtils.isBlank(this.value) ? this.body : this.value; value = CaptureUtil.nullToEmpty(value); if (!duplicate && current.contains(value)) { return;//from w ww . j av a 2 s . c o m } if (addFirst) { current.addFirst(value); } else { current.add(value); } pageContext.setAttribute(name, current, PageContext.REQUEST_SCOPE); }
From source file:ru.runa.wfe.extension.orgfunction.DemoSubordinateRecursive.java
/** * @param subordinatesList/*from w ww . java2s .com*/ * @param flag * @param newSubordinates * @return */ private int addNotContainedElements(LinkedList<Actor> subordinatesList, LinkedList<Actor> newGeneratedSubordinates) { int flag = 0; for (ListIterator<Actor> iter = newGeneratedSubordinates.listIterator(); iter.hasNext();) { Actor acurr = iter.next(); if (!subordinatesList.contains(acurr)) { subordinatesList.add(acurr); flag = -1; } } return flag; }
From source file:net.erdfelt.android.sdkfido.configer.ConfigCmdLineParser.java
public void parse(String[] args) throws CmdLineParseException { LinkedList<String> arglist = new LinkedList<String>(); arglist.addAll(Arrays.asList(args)); // Quick Help if (arglist.contains("--" + OPT_HELP)) { usage();/*from ww w .ja va 2 s . c om*/ return; } // Configuration File Option int idx = arglist.indexOf("--" + OPT_CONFIG); if (idx >= 0) { if (idx + 1 > arglist.size()) { throw new CmdLineParseException("Expected <File> parameter for option: --" + OPT_CONFIG); } String value = arglist.get(idx + 1); File file = (File) ConvertUtils.convert(value, File.class); this.configer.setPersistFile(file); arglist.remove(idx + 1); arglist.remove(idx); } // Save Options Option boolean saveOptions = false; idx = arglist.indexOf("--" + OPT_SAVE); if (idx >= 0) { saveOptions = true; arglist.remove(idx); } // Restore from persist first. try { configer.restore(); } catch (IOException e) { throw new CmdLineParseException("Unable to load configuration: " + e.getMessage(), e); } // Set values from command line now. String value; ListIterator<String> iter = arglist.listIterator(); while (iter.hasNext()) { String arg = iter.next(); if (arg.startsWith("--")) { // Its an option. String optname = arg.substring(2); Configurable cfgrbl = configer.getConfigurable(optname); if (cfgrbl == null) { throw new CmdLineParseException("Invalid Option: " + arg); } if (!iter.hasNext()) { throw new CmdLineParseException( "Expected <" + cfgrbl.getType() + "> parameter for option: " + arg); } value = iter.next(); configer.setValue(optname, value); continue; // process next arg } // All others are considered args. addToRawArgs(arg); } // Save options (if specified) if (saveOptions) { try { configer.persist(); } catch (IOException e) { throw new CmdLineParseException("Unable to save configuration: " + e.getMessage(), e); } } }