List of usage examples for java.util LinkedList get
public E get(int index)
From source file:comingle.dragracing.TrackActivity.java
public void renderTrack(LinkedList<Integer> locs) { //decide phone_order for rendering tracks for (int x = 0; x < locs.size(); x++) { if (locs.get(x) == this.getLocation()) { if (x > 0) { initTrack(locs.size() - 1, 1); }//from w ww .j a va 2 s . c om if (x < locs.size() - 1) { initTrack(locs.size() - 1, 0); break; } } } initMarkers(locs); }
From source file:org.guzz.GuzzContextImpl.java
protected void initUnOrderedService(Map services, LinkedList queuedServices, ServiceInfo serviceInfo) { if (serviceInfo.hasDependedServices()) { queuedServices.addLast(serviceInfo); String[] dependsOn = serviceInfo.getDependedServices(); for (int k = 0; k < dependsOn.length; k++) { for (int i = 0; i < queuedServices.size(); i++) { String queueServiceName = ((ServiceInfo) queuedServices.get(i)).getServiceName(); if (queueServiceName.equals(dependsOn[k])) { throw new InvalidConfigurationException("cycle dependencies found in guzz services. From [" + queueServiceName + "] to [" + dependsOn[k] + "]."); }/* www. j av a2s . c o m*/ } //add depended-services from un-inited-services to the queuedServices ServiceInfo si = (ServiceInfo) services.remove(dependsOn[k]); if (si != null) { //process the depended service first. initUnOrderedService(services, queuedServices, si); } else { //the service may have already been registered to the ServiceManager } } //Depended services have been inited. Start the current one. Service s = ServiceManagerImpl.createNewService(this, configServer, serviceInfo); serviceManager.registerService(s); queuedServices.remove(serviceInfo); } else { Service s = ServiceManagerImpl.createNewService(this, configServer, serviceInfo); serviceManager.registerService(s); } }
From source file:org.trnltk.tokenizer.TextTokenizerTrainer.java
void createRules(List<TextBlock> untokenizedTextBlocks, LinkedList<TextBlock> tokenizedTextBlocks) { this.textBlockSplitter.addTextStartsAndEnds(untokenizedTextBlocks, blockSize); this.textBlockSplitter.addTextStartsAndEnds(tokenizedTextBlocks, blockSize); int i = this.blockSize; //untokenizedBlocksIndex int j = this.blockSize; //tokenizedBlocksIndex while (true) { boolean addSpace; //we're out ot untokenizedBlocks if (i > untokenizedTextBlocks.size() - this.blockSize) { // assume we're out of tokenized blocks too // unless tokenized training str ends with space. but we don't allow it anyway Validate.isTrue(j > tokenizedTextBlocks.size() - this.blockSize); break; } else {//w ww . j a v a 2s .c o m if (untokenizedTextBlocks.get(i).equals(tokenizedTextBlocks.get(j))) { //then there is no space! addSpace = false; } else if (untokenizedTextBlocks.get(i).equals(tokenizedTextBlocks.get(j + 1))) { Validate.isTrue(tokenizedTextBlocks.get(j).equals(SPACE_TEXT_BLOCK)); addSpace = true; } else { throw new IllegalStateException("Found wrong aligned blocks. Possible causes : \n" + "\t * There difference in two texts (tokenized and untokenized) other than space\n" + "\t * There are more than one space in a row in one or both of the texts"); } } //get left from untokenized blocks and right from untokenized blocks final TextBlockGroup leftTextBlockGroup = this.textBlockSplitter .getTextBlockGroup(untokenizedTextBlocks, this.blockSize, i - blockSize); final TextBlockGroup rightTextBlockGroup = this.textBlockSplitter .getTextBlockGroup(untokenizedTextBlocks, this.blockSize, i); this.addTokenizationRule(leftTextBlockGroup, rightTextBlockGroup, addSpace); if (addSpace) j++; //align i++; j++; } }
From source file:eu.uqasar.model.tree.TreeNode.java
@SuppressWarnings("unchecked") @Override//from w w w . ja v a 2s. c o m public boolean changePositionWithPreviousSibling(boolean changeParents) { LinkedList<TreeNode> directSiblings = (LinkedList<TreeNode>) getMutableSiblings(); int currentIndex = directSiblings.indexOf(this); int newIndex = currentIndex - 1; if (currentIndex > 0) { // switch currently selected node with the previous one TreeNode movedNode = directSiblings.remove(currentIndex); directSiblings.add(newIndex, movedNode); getParent().setChildren(directSiblings); logger.info(String.format("Moving %s from index %s to %s", this, currentIndex, newIndex)); return true; } else if (currentIndex == 0 && changeParents) { // add currently selected node as last entry to the previous // parent sibling LinkedList<TreeNode> parentSiblings = (LinkedList<TreeNode>) this.getParent().getMutableSiblings(); int parentIndex = parentSiblings.indexOf(this.getParent()); int newParentIndex = parentIndex - 1; if (parentIndex > 0) { TreeNode oldParent = this.getParent(); LinkedList<TreeNode> oldParentChildren = oldParent.getChildren(); oldParentChildren.remove(0); oldParent.setChildren(oldParentChildren); TreeNode newParent = parentSiblings.get(newParentIndex); logger.info(String.format("Moving %s from parent %s to %s", this, this.getParent(), newParent)); this.setParent(newParent); return true; } } return false; }
From source file:nl.strohalm.cyclos.services.transfertypes.AuthorizationLevelServiceImpl.java
private AuthorizationLevel getLowerLevel(final AuthorizationLevel authorizationLevel) { final TransferType transferType = authorizationLevel.getTransferType(); final LinkedList<AuthorizationLevel> authorizationLevels = new LinkedList<AuthorizationLevel>( transferType.getAuthorizationLevels()); if (CollectionUtils.isEmpty(authorizationLevels)) { return null; }//from w ww . j a v a 2 s.c o m final Integer currentLevel = authorizationLevel.getLevel(); if (currentLevel == null) { // We are inserting a new authorization level, the lower level is the highest level saved return authorizationLevels.getLast(); } else { // We are updating a saved authorization level if (currentLevel == 1 || authorizationLevels.size() == 1) { return null; } // List indexes start with 0 return authorizationLevels.get(currentLevel - 2); } }
From source file:net.gaast.giggity.ScheduleViewActivity.java
public void showDayDialog() { LinkedList<Date> days = sched.getDays(); CharSequence dayList[] = new CharSequence[days.size()]; int i, cur = -1; for (i = 0; i < days.size(); i++) { if (sched.getDay().equals(days.get(i))) cur = i;//w ww . j a v a2 s .c om dayList[i] = dateFormat.format(days.get(i)); } if (days.size() == 2) { /* If there are only two days, don't bother showing the dialog, even * though we did promise to show it. :-P */ sched.getDb().setDay(1 - cur); redrawSchedule(); return; } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.change_day); builder.setSingleChoiceItems(dayList, cur, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { sched.getDb().setDay(item); redrawSchedule(); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.kitodo.production.forms.dataeditor.StructurePanel.java
private void checkPhysicalDragDrop(MediaUnit dragUnit, MediaUnit dropUnit) { StructuralElementViewInterface divisionView = dataEditor.getRuleset().getStructuralElementView( dropUnit.getType(), dataEditor.getAcquisitionStage(), dataEditor.getPriorityList()); LinkedList<MediaUnit> dragParents; if (divisionView.getAllowedSubstructuralElements().containsKey(dragUnit.getType())) { dragParents = MetadataEditor.getAncestorsOfMediaUnit(dragUnit, dataEditor.getWorkpiece().getMediaUnit()); if (dragParents.isEmpty()) { Helper.setErrorMessage("No parents of media unit " + dragUnit.getType() + " found!"); } else {/*from w ww . j a v a2 s . c om*/ MediaUnit parentUnit = dragParents.get(dragParents.size() - 1); if (parentUnit.getChildren().contains(dragUnit)) { preservePhysical(); return; } else { Helper.setErrorMessage( "Parents of media unit " + dragUnit.getType() + " do not contain media " + "unit!"); } } } else { Helper.setErrorMessage("Media unit of type '" + dragUnit.getType() + "' NOT allowed as child of media unit of type '" + dropUnit.getType() + "!"); } show(); }
From source file:org.apache.activemq.leveldb.test.ReplicatedLevelDBStoreTest.java
@Test(timeout = 1000 * 60 * 10) public void testReplication() throws Exception { LinkedList<File> directories = new LinkedList<File>(); directories.add(new File("target/activemq-data/leveldb-node1")); directories.add(new File("target/activemq-data/leveldb-node2")); directories.add(new File("target/activemq-data/leveldb-node3")); resetDirectories(directories);/*from www.ja v a 2 s.c o m*/ // For some reason this had to be 64k to trigger a bug where // slave index snapshots were being done incorrectly. String playload = createPlayload(64 * 1024); ArrayList<String> expected_list = new ArrayList<String>(); // We will rotate between 3 nodes the task of being the master. for (int j = 0; j < 5; j++) { MasterLevelDBStore master = createMaster(directories.get(0)); CountDownFuture masterStart = asyncStart(master); SlaveLevelDBStore slave1 = createSlave(master, directories.get(1)); SlaveLevelDBStore slave2 = createSlave(master, directories.get(2)); asyncStart(slave2); masterStart.await(); if (j == 0) { stores.add(master); stores.add(slave1); stores.add(slave2); } MessageStore ms = master.createQueueMessageStore(new ActiveMQQueue("TEST")); LOG.info("Checking: " + master.getDirectory()); assertEquals(expected_list, getMessages(ms)); LOG.info("Adding messages..."); final int TOTAL = 500; for (int i = 0; i < TOTAL; i++) { if (i % ((int) (TOTAL * 0.10)) == 0) { LOG.info("" + (100 * i / TOTAL) + "% done"); } if (i == 250) { slave1.start(); slave2.stop(); LOG.info("Checking: " + master.getDirectory()); assertEquals(expected_list, getMessages(ms)); } String msgid = "m:" + j + ":" + i; addMessage(ms, msgid, playload); expected_list.add(msgid); } LOG.info("Checking: " + master.getDirectory()); assertEquals(expected_list, getMessages(ms)); LOG.info("Stopping master: " + master.getDirectory()); master.stop(); Thread.sleep(3 * 1000); LOG.info("Stopping slave: " + slave1.getDirectory()); slave1.stop(); // Rotate the dir order so that slave1 becomes the master next. directories.addLast(directories.removeFirst()); } }
From source file:eu.uqasar.model.tree.TreeNode.java
@SuppressWarnings("unchecked") @Override//from ww w . java 2 s. co m public boolean changePositionWithNextSibling(boolean changeParents) { LinkedList<TreeNode> directSiblings = (LinkedList<TreeNode>) getMutableSiblings(); int currentIndex = directSiblings.indexOf(this); int newIndex = currentIndex + 1; if (newIndex < directSiblings.size()) { // switch currently selected node with the next one TreeNode movedNode = directSiblings.remove(currentIndex); directSiblings.add(newIndex, movedNode); getParent().setChildren(directSiblings); logger.info(String.format("Moving %s from index %s to %s", this, currentIndex, newIndex)); return true; } else if (newIndex >= directSiblings.size() && changeParents) { // add currently selected node as first entry to the next parent // sibling LinkedList<TreeNode> parentSiblings = (LinkedList<TreeNode>) this.getParent().getMutableSiblings(); int parentIndex = parentSiblings.indexOf(this.getParent()); int newParentIndex = parentIndex + 1; if (newParentIndex < parentSiblings.size()) { TreeNode oldParent = this.getParent(); LinkedList<TreeNode> oldParentChildren = oldParent.getChildren(); oldParentChildren.removeLast(); oldParent.setChildren(oldParentChildren); TreeNode newParent = parentSiblings.get(newParentIndex); logger.info(String.format("Moving %s from parent %s to %s", this, this.getParent(), newParent)); this.setParent(newParent); return true; } } return false; }
From source file:estimatePressure.EstimatePressureValues.java
void prepareTraingData(LinkedList<String> orientationList) { //System.out.println("Oriention values in testing: " + orientationList); ArrayList<Double> orientationAngles = new ArrayList<Double>(); for (int i = 0; i < this.inputDim; i++) { if (this.useAngles) { //use below line for angle with z component //orientationAngles.add( Double.parseDouble(orientationList.get(i + 3)) ); double angle = Double.parseDouble(orientationList.get(i + 3)); if (i < 2) { // scale down the x and y angles as x and y ~= 91.00 or // 89.00 and z is =~ -1.00 to 1.00 so that all three angels // have same range , this helps in regulating the values of // sigmoid function angle = angle - 90;// w w w.j a v a 2 s . co m } orientationAngles.add(angle); } else { // use below line for x,y,z components //orientationAngles.add(Double.parseDouble(orientationList.get(i))); // scale down the z components as x and y ~= 0 to 100 // and z is =~ -10000.00 so that all three components // have same range , this helps in regulating the values of // sigmoid function double values = Double.parseDouble(orientationList.get(i)); if (i == 2) { values = values + 23500; } values = values / 100; orientationAngles.add(values); } } this.trainingInputList.add(orientationAngles); ArrayList<Double> pressureValues = new ArrayList<Double>(); pressureValues.add(this.avgTopBotLeftLine); pressureValues.add(this.avgBotBotLeftLine); pressureValues.add(this.avgTopTopLeftLine); pressureValues.add(this.avgBotTopLeftLine); pressureValues.add(this.avgBotBotRightLine); pressureValues.add(this.avgTopBotRightLine); pressureValues.add(this.avgTopTopRightLine); pressureValues.add(this.avgBotTopRightLine); this.expectedValuesList.add(pressureValues); this.numSample++; }