Java Code Examples for java.util.LinkedList#addFirst()

The following examples show how to use java.util.LinkedList#addFirst() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InlineDeAssigner.java    From cfr with MIT License 6 votes vote down vote up
private void deAssign(AssignmentSimple assignmentSimple, Op03SimpleStatement container, List<Op03SimpleStatement> added) {
    Expression rhs = assignmentSimple.getRValue();
    if (rhs instanceof LValueExpression || rhs instanceof Literal) return;
    Deassigner deassigner = new Deassigner();
    LinkedList<LValue> lValues = ListFactory.newLinkedList();
    while (rhs instanceof AssignmentExpression) {
        AssignmentExpression assignmentExpression = (AssignmentExpression)rhs;
        lValues.addFirst(assignmentExpression.getlValue());
        rhs = assignmentExpression.getrValue();
    }

    Expression rhs2 = deassigner.rewriteExpression(rhs, container.getSSAIdentifiers(), container, ExpressionRewriterFlags.RVALUE);
    if (deassigner.extracted.isEmpty()) return;
    for (LValue outer : lValues) {
        rhs2 = new AssignmentExpression(outer, rhs2);
    }
    assignmentSimple.setRValue(rhs2);
    rewrite(deassigner, container, added);
}
 
Example 2
Source File: Astar.java    From javagame with MIT License 6 votes vote down vote up
/**
 * �S�[���m�[�h�܂ł̃p�X���\�z����
 * 
 * @param node �S�[���m�[�h
 * @return �X�^�[�g�m�[�h����S�[���m�[�h�܂ł̃p�X
 */
private LinkedList constructPath(Node node) {
    LinkedList path = new LinkedList();

    // �e�m�[�h�����X���ǂ�
    while (node.parentNode != null) {
        // �ŏ��ɒlj�����̂��~�\
        // �X�^�[�g�m�[�h��LinkedList�̐擪
        // �S�[���m�[�h��LinkedList�̍Ō�ɂȂ�悤�ɂ���
        path.addFirst(node);
        node = node.parentNode;
    }

    // �X�^�[�g�m�[�h�inode.parentNode == null�ƂȂ�m�[�h�j
    // ���lj�������
    path.addFirst(node);

    return path;
}
 
Example 3
Source File: SyncerApplication.java    From syncer with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void run(String[] args) throws Exception {
  LinkedList<Starter> starters = new LinkedList<>();
  HashSet<String> consumerIds = new HashSet<>();
  for (ConsumerConfig consumerConfig : consumerConfigs) {
    if (!validPipeline(consumerConfig)) {
      continue;
    }
    if (consumerIds.contains(consumerConfig.getConsumerId())) {
      throw new InvalidConfigException("Duplicate consumerId: " + consumerConfig.getConsumerId());
    }
    consumerIds.add(consumerConfig.getConsumerId());
    starters.add(new ConsumerStarter(consumerConfig, syncerConfig, consumerRegistry).start());
  }
  // add producer as first item, stop producer first
  starters.addFirst(ProducerStarter
      .getInstance(producerConfig.getInput(), syncerConfig.getInput(), consumerRegistry)
      .start());

  Runtime.getRuntime().addShutdownHook(new WaitingAckHook(starters));

  SyncerHealth.init(starters);
  ExportServer.init(args);
}
 
Example 4
Source File: PsiFileBreadcrumbsCollector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nullable
private static Collection<Pair<PsiElement, BreadcrumbsProvider>> getLineElements(Document document,
                                                                                 int offset,
                                                                                 VirtualFile file,
                                                                                 Project project,
                                                                                 BreadcrumbsProvider defaultInfoProvider,
                                                                                 boolean checkSettings) {
  PsiElement element = findStartElement(document, offset, file, project, defaultInfoProvider, checkSettings);
  if (element == null) return null;

  LinkedList<Pair<PsiElement, BreadcrumbsProvider>> result = new LinkedList<>();
  while (element != null) {
    BreadcrumbsProvider provider = findProviderForElement(element, defaultInfoProvider, checkSettings);

    if (provider != null && provider.acceptElement(element)) {
      result.addFirst(Pair.create(element, provider));
    }

    element = getParent(element, provider);
    if (element instanceof PsiDirectory) break;
  }
  return result;
}
 
Example 5
Source File: HttpInterfaceServiceImpl.java    From AnyMock with Apache License 2.0 6 votes vote down vote up
private HttpInterfaceDTO convertToDTO(HttpInterfaceBO httpInterfaceBO) {
    HttpInterfaceDTO httpInterfaceDTO = new HttpInterfaceDTO();
    BeanUtils.copyProperties(httpInterfaceBO, httpInterfaceDTO);

    // path
    Long spaceId = httpInterfaceBO.getSpaceId();
    LinkedList<Long> path = new LinkedList<>();
    while (!spaceId.equals(ROOT_SPACE_ID)) {
        path.addFirst(spaceId);
        spaceId = spaceDao.queryById(spaceId).getParentId();
    }
    httpInterfaceDTO.setPath(path);

    // variable
    httpInterfaceDTO.setVariable(PrivilegeVerifier.hasPermission(httpInterfaceBO.getAccessAuthority()));
    return httpInterfaceDTO;
}
 
Example 6
Source File: Array.java    From vespa with Apache License 2.0 5 votes vote down vote up
FieldPathIteratorHandler.ModificationStatus iterateSubset(int startPos, int endPos, FieldPath fieldPath, String variable, int nextPos, FieldPathIteratorHandler handler) {
    FieldPathIteratorHandler.ModificationStatus retVal = FieldPathIteratorHandler.ModificationStatus.NOT_MODIFIED;

    LinkedList<Integer> indicesToRemove = new LinkedList<Integer>();

    for (int i = startPos; i <= endPos && i < values.size(); i++) {
        if (variable != null) {
            handler.getVariables().put(variable, new FieldPathIteratorHandler.IndexValue(i));
        }

        FieldValue fv = values.get(i);
        FieldPathIteratorHandler.ModificationStatus status = fv.iterateNested(fieldPath, nextPos, handler);

        if (status == FieldPathIteratorHandler.ModificationStatus.REMOVED) {
            indicesToRemove.addFirst(i);
            retVal = FieldPathIteratorHandler.ModificationStatus.MODIFIED;
        } else if (status == FieldPathIteratorHandler.ModificationStatus.MODIFIED) {
            retVal = status;
        }
    }

    if (variable != null) {
        handler.getVariables().remove(variable);
    }

    for (Integer idx : indicesToRemove) {
        values.remove(idx.intValue());
    }
    return retVal;
}
 
Example 7
Source File: TestsLocationProviderUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static List<VirtualFile> findSuitableFilesFor(final String filePath, final Project project) {
  final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();

  // at first let's try to find file as is, by it's real path
  // and check that file belongs to current project
  // this location provider designed for tests thus we will check only project content
  // (we cannot check just sources or tests folders because RM doesn't use it
  final VirtualFile file = getByFullPath(filePath);
  final boolean inProjectContent = file != null && (index.isInContent(file));

  if (inProjectContent) {
    return Collections.singletonList(file);
  }

  //split file by "/" in parts
  final LinkedList<String> folders = new LinkedList<String>();
  final StringTokenizer st = new StringTokenizer(filePath, "/", false);
  String fileName = null;
  while (st.hasMoreTokens()) {
    final String pathComponent = st.nextToken();
    if (st.hasMoreTokens()) {
      folders.addFirst(pathComponent);
    } else {
      // last token
      fileName = pathComponent;
    }
  }
  if (fileName == null) {
    return Collections.emptyList();
  }
  return findFilesClosestToTarget(folders, collectCandidates(project, fileName, true), MIN_PROXIMITY_THRESHOLD);
}
 
Example 8
Source File: Filter.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link com.google.cloud.backend.core.Filter} for IN operation.
 *
 * @param propertyName Name of the target property.
 * @param values any number of {@link Object}s for the IN operation.
 * @return {@link com.google.cloud.backend.core.Filter} for this operation.
 */
public static Filter in(String propertyName, List<Object> values) {
    LinkedList<Object> l = new LinkedList<Object>(values);
    l.addFirst(propertyName);
    Filter f = new Filter();
    f.filterDto.setOperator(Op.IN.name());
    f.filterDto.setValues(l);
    return f;
}
 
Example 9
Source File: UiBindingRegistry.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void registerMouseBinding(boolean first, MouseEventTypeEnum mouseEventType, IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
	LinkedList<MouseBinding> mouseEventBindings = mouseBindingsMap.get(mouseEventType);
	if (mouseEventBindings == null) {
		mouseEventBindings = new LinkedList<MouseBinding>();
		mouseBindingsMap.put(mouseEventType, mouseEventBindings);
	}
	if (first) {
		mouseEventBindings.addFirst(new MouseBinding(mouseEventMatcher, action));
	} else {
		mouseEventBindings.addLast(new MouseBinding(mouseEventMatcher, action));
	}
}
 
Example 10
Source File: TaskManagerImpl.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
@Override
public List<Task> getTasksInDocumentOrder() {
  List<Task> result = Lists.newArrayList();
  LinkedList<Task> deque = new LinkedList<>();
  deque.addFirst(getRootTask());
  while (!deque.isEmpty()) {
    Task head = deque.poll();
    result.add(head);
    deque.addAll(0, Arrays.asList(head.getNestedTasks()));
  }
  result.remove(0);
  return result;
}
 
Example 11
Source File: DeepEquals.java    From asf-sdk with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Deeply compare two SortedMap instances.  This method walks the Maps in order,
 * taking advantage of the fact that the Maps are SortedMaps.
 *
 * @param map1 SortedMap one
 * @param map2 SortedMap two
 * @param stack add items to compare to the Stack (Stack versus recursion)
 * @param visited Set containing items that have already been compared, to prevent cycles.
 *
 * @return false if the Maps are for certain not equals.  'true' indicates that 'on the surface'
 * the maps
 * are equal, however, it will place the contents of the Maps on the stack for further
 * comparisons.
 */
private static boolean compareSortedMap(SortedMap map1, SortedMap map2, LinkedList stack,
    Set visited) {
  // Same instance check already performed...

  if (map1.size() != map2.size()) {
    return false;
  }

  Iterator i1 = map1.entrySet()
      .iterator();
  Iterator i2 = map2.entrySet()
      .iterator();

  while (i1.hasNext()) {
    Entry entry1 = (Entry) i1.next();
    Entry entry2 = (Entry) i2.next();

    // Must split the Key and Value so that Map.Entry's equals() method is not used.
    DualKey dk = new DualKey(entry1.getKey(), entry2.getKey());
    if (!visited.contains(dk)) {   // Push Keys for further comparison
      stack.addFirst(dk);
    }

    dk = new DualKey(entry1.getValue(), entry2.getValue());
    if (!visited.contains(dk)) {   // Push values for further comparison
      stack.addFirst(dk);
    }
  }
  return true;
}
 
Example 12
Source File: FileProps.java    From live-chat-engine with Apache License 2.0 5 votes vote down vote up
public static List<FileProps> createFileProps(Collection<String> paths){
	LinkedList<FileProps> list = new LinkedList<>();
	for (String path : paths) {
		File file = new File(path);
		if( ! file.exists()){
			log.error("can't find file by path: "+path);
			continue;
		}
		list.addFirst(new FileProps(file));
	}
	return list;
}
 
Example 13
Source File: UiBindingRegistry.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void registerMouseBinding(boolean first, MouseEventTypeEnum mouseEventType, IMouseEventMatcher mouseEventMatcher, IMouseAction action) {
	LinkedList<MouseBinding> mouseEventBindings = mouseBindingsMap.get(mouseEventType);
	if (mouseEventBindings == null) {
		mouseEventBindings = new LinkedList<MouseBinding>();
		mouseBindingsMap.put(mouseEventType, mouseEventBindings);
	}
	if (first) {
		mouseEventBindings.addFirst(new MouseBinding(mouseEventMatcher, action));
	} else {
		mouseEventBindings.addLast(new MouseBinding(mouseEventMatcher, action));
	}
}
 
Example 14
Source File: ConfigService.java    From mapper-generator-javafx with Apache License 2.0 5 votes vote down vote up
/**
 * 添加配置
 *
 * @param generatorConfig 配置信息
 * @return 1:原来文件被修改;2:已存在配置且和原来配置相同;3:新配置
 */
public int addConfig(GeneratorConfig generatorConfig) {
    File configFile = BaseConstants.getConfigFile();
    LinkedList<GeneratorConfig> generatorConfigs;
    if (configFile.exists()) {
        generatorConfigs = this.loadConfigFromFile();
    } else {
        generatorConfigs = new LinkedList<>();
    }

    LinkedList<GeneratorConfig> existConfigLinkedList = generatorConfigs.stream().filter(generatorConfig1 -> generatorConfig.getConfigName().equals(generatorConfig1.getConfigName())).collect(Lists::newLinkedList, LinkedList::add, List::addAll);

    //配置已存在,如果内容修改,则修改
    if (!existConfigLinkedList.isEmpty()) {
        GeneratorConfig olderConfig = existConfigLinkedList.getFirst();
        boolean isSame = BeanUtils.checkPropertyOfBean(generatorConfig, olderConfig);
        if (!isSame) {
            existConfigLinkedList.remove(olderConfig);
            existConfigLinkedList.addFirst(generatorConfig);
            this.downLoadConfigToFile(existConfigLinkedList);
            return 1;
        } else {
            return 2;
        }
    } else {
        generatorConfigs.addFirst(generatorConfig);
        this.downLoadConfigToFile(generatorConfigs);
        return 3;
    }
}
 
Example 15
Source File: ChatController.java    From ChatRoom-JavaFX with Apache License 2.0 4 votes vote down vote up
/**
 * 设置在线用户列表,并显示在线人数(需要在列表中排除本机用户)
 * @param userInfolist 用户集
 */
public void setUserList(LinkedList<UserInfo> userInfolist) {

	this.userInfoList = userInfolist;
	/*
	System.out.print("UserList:");
	for(UserInfo user: userInfolist){
		System.out.println(user.getUsername());
	}
	*/

	//为listview数据源准备ALL所有人选项
	if(!userInfolist.getFirst().equals(Utils.ALL)){
		UserInfo allUser = new UserInfo(Utils.ALL,"All.png");
		userInfolist.addFirst(allUser);
	}
	//在线用户数量
	int userCount = userInfolist.size()-1;

	//本机用户不需要显示
	for(UserInfo user : userInfolist){
		if(user.getUsername().equals(userName)){
			userInfolist.remove(user);
			break;//注意缺少break会出bug,因为遍历中ArrayList不可变。使用Iterator的方式也可以顺利删除和遍历。
		}
	}
	//设置在线用户列表
	Platform.runLater(() -> {

		//ListView清除焦点
		 userListView.getSelectionModel().clearSelection();
		 //数据源
		 ObservableList<UserInfo> users = FXCollections.observableList(userInfolist);
		 userListView.setItems(users);
		 //自定义ListView
		 userListView.setCellFactory((ListView<UserInfo> L) -> new UsersCell());

		 //设置在线用户人数
		 userCountLabel.setText(userCount + "");

	 });

	/**
	 * userListView列表项点击事件监视器
	 */
	userListView.getSelectionModel().selectedItemProperty().addListener(
			(ObservableValue<? extends UserInfo> ov, UserInfo old_val,
					UserInfo new_val) -> {
						//solve bug
						if(new_val == null){
							otherUserNameLabel.setText("Welcome to ChatRoom");
							return;
						}

						otherUserName = new_val.getUsername();
						if(otherUserName.equals(Utils.ALL)){
							otherUserNameLabel.setText("Chat with everyone..");
						}else {
							//System.out.println(new_val.getUsername());
							otherUserNameLabel.setText("Chat with " + otherUserName +":");
						}
					});

}
 
Example 16
Source File: EngineTask.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
private void loadReportletDataSource( ReportDocumentReader document,
		IDocArchiveReader dataSource, String reportletBookmark )
		throws EngineException, IOException
{

	InstanceID reportletIid = null;
	if ( document.isReporltetDocument( ) )
	{
		String bookmark = document.getReportletBookmark( );
		if ( !reportletBookmark.equals( bookmark ) )
		{
			throw new EngineException(
					"The user must specify the same reportlet with the one used to generate the document" );
		}
		reportletIid = document.getReportletInstanceID( );
	}
	else
	{
		// load the result set used by reportlet
		long offset = document.getBookmarkOffset( reportletBookmark );
		if ( offset == -1 )
		{
			throw new EngineException(
					"The user specified reportlet {0} doesn''t exits in the report document",
					new Object[]{reportletBookmark} );
		}

		ClassLoader loader = document.getClassLoader( );
		RAInputStream in = dataSource
				.getInputStream( ReportDocumentConstants.CONTENT_STREAM );
		try
		{
			ReportContentReaderV3 reader = new ReportContentReaderV3(
					new ReportContent( ), in, loader );
			try
			{
				LinkedList<InstanceID> iids = new LinkedList<InstanceID>( );
				while ( offset != -1 )
				{
					IContent content = reader.readContent( offset );
					iids.addFirst( content.getInstanceID( ) );
					offset = ( (DocumentExtension) content
							.getExtension( IContent.DOCUMENT_EXTENSION ) )
							.getParent( );
				}

				for ( InstanceID iid : iids )
				{
					if ( reportletIid == null )
					{
						reportletIid = iid;
					}
					else
					{
						reportletIid = new InstanceID( reportletIid, iid );
					}
				}
			}
			finally
			{
				reader.close( );
			}
		}
		finally
		{
			in.close( );
		}
	}
	// set the datasources
	executionContext.setDataSource( new DocumentDataSource( dataSource,
			reportletBookmark, reportletIid ) );
}
 
Example 17
Source File: TypeUsageUtils.java    From cfr with MIT License 4 votes vote down vote up
static String generateInnerClassShortName(final IllegalIdentifierDump iid, final JavaRefTypeInstance clazz, JavaRefTypeInstance analysisType, boolean prefixAnalysisType) {
    LinkedList<JavaRefTypeInstance> classStack = ListFactory.newLinkedList();

    boolean analysisTypeFound = false;
    if (clazz.getRawName().startsWith(analysisType.getRawName())) {
        // In case we don't have full info.
        // This is, at best, a guess.
        String possible = clazz.getRawName().substring(analysisType.getRawName().length());
        if (!possible.isEmpty()) {
            switch (possible.charAt(0)) {
                case '$':
                case '.':
                    analysisTypeFound = true;
                    break;
            }
        }
    }
    JavaRefTypeInstance currentClass = clazz;
    boolean first = true;
    do {
        InnerClassInfo innerClassInfo = currentClass.getInnerClassHereInfo();
        // Need to skip anonymous classes, see (eg) anonymousInnerClassTest3.
        if (!innerClassInfo.isAnonymousClass() || first) {
            classStack.addFirst(currentClass);
        }
        first = false;
        if (!innerClassInfo.isInnerClass()) {
            break;
        }
        currentClass = innerClassInfo.getOuterClass();
        if (currentClass.equals(analysisType)) {
            analysisTypeFound = true;
            break;  // We don't want to go any further back than here!
        }
    } while (true);
    /*
     * Local inner class.  We want the smallest postfix.  We can drop the local class, but because we're not doing
     * imports for local classes, we can't drop any more.
     */
    if (analysisTypeFound == currentClass.equals(analysisType)) {
        StringBuilder sb = new StringBuilder();
        first = true;
        /*
         * if we've been overridden, we need to prefix the analysis type. (See ShortNameTest5)
         */
        if (prefixAnalysisType) {
            sb.append(analysisType.getRawShortName(iid));
            first = false;
        }

        for (JavaRefTypeInstance stackClass : classStack) {
            first = StringUtils.dot(first, sb);
            sb.append(stackClass.getRawShortName(iid));
        }
        return sb.toString();
    } else {
        // string approximation.
        String clazzRawName = clazz.getRawName(iid);
        // Cheat using $.
        String analysisTypeRawName = analysisType.getRawName(iid);

        if (clazzRawName.equals(analysisTypeRawName)) {
            int idx = clazzRawName.lastIndexOf('.');
            if (idx >= 1 && idx < (clazzRawName.length() - 1)) {
                return clazzRawName.substring(idx + 1);
            }
        }

        if (analysisTypeRawName.length() >= (clazzRawName.length() - 1)) {
            return clazzRawName;
        }
        return clazzRawName.substring(analysisType.getRawName().length() + 1);
    }
}
 
Example 18
Source File: DataCollector.java    From deltachat-android with GNU General Public License v3.0 4 votes vote down vote up
public void updateSource(int chatId,
                          int contactId,
                          long startTimestamp,
                          long endTimestamp) {
    DcArray locations = dcContext.getLocations(chatId, contactId, startTimestamp, endTimestamp);

    MapSource contactMapMetadata = contactMapSources.get(contactId);
    if (contactMapMetadata == null) {
        contactMapMetadata = addContactMapSource(contactMapSources, contactId);
    }
    int count = locations.getCnt();

    LinkedList<Feature> sortedPointFeatures = featureCollections.get(contactMapMetadata.getMarkerFeatureCollection());
    if (sortedPointFeatures != null && sortedPointFeatures.size() == count) {
        return;
    } else {
        sortedPointFeatures = new LinkedList<>();
    }
    LinkedList<Feature> sortedLineFeatures = new LinkedList<>();

    for (int i = count - 1; i >= 0; i--) {
        Point point = Point.fromLngLat(locations.getLongitude(i), locations.getLatitude(i));

        String codepointChar =
                locations.getMarker(i) != null ?
                        locations.getMarker(i) :
                        "";
        boolean isPoi = locations.isIndependent(i);
        int messageId = locations.getMsgId(i);

        Feature pointFeature = Feature.fromGeometry(point, new JsonObject(), String.valueOf(locations.getLocationId(i)));
        pointFeature.addBooleanProperty(MARKER_SELECTED, false);
        pointFeature.addBooleanProperty(LAST_LOCATION, false);
        pointFeature.addNumberProperty(CONTACT_ID, contactId);
        pointFeature.addNumberProperty(TIMESTAMP, locations.getTimestamp(i));
        pointFeature.addNumberProperty(MESSAGE_ID, messageId);
        pointFeature.addNumberProperty(ACCURACY, locations.getAccuracy(i));
        pointFeature.addStringProperty(MARKER_CHAR, codepointChar);
        pointFeature.addStringProperty(MARKER_ICON, isPoi ?
                contactMapMetadata.getMarkerPoi() :
                contactMapMetadata.getMarkerIcon());
        pointFeature.addBooleanProperty(IS_POI, isPoi);
        if (isPoi && codepointChar.length() == 0 && messageId != 0) {
            //has a long poi label
            DcMsg poiMsg = dcContext.getMsg(messageId);
            String poiLongDescription = poiMsg.getText();
            pointFeature.addStringProperty(POI_LONG_DESCRIPTION, poiLongDescription);
        }

        sortedPointFeatures.addFirst(pointFeature);

        if (!locations.isIndependent(i) && sortedPointFeatures.size() > 1) {
            Point lastPoint = (Point) sortedPointFeatures.get(1).geometry();
            ArrayList<Point> lineSegmentPoints = new ArrayList<>(3);
            lineSegmentPoints.add(lastPoint);
            lineSegmentPoints.add(point);
            LineString l = LineString.fromLngLats(lineSegmentPoints);
            Feature lineFeature = Feature.fromGeometry(l, new JsonObject(), "l_" + pointFeature.id());
            lineFeature.addNumberProperty(TIMESTAMP, pointFeature.getNumberProperty(TIMESTAMP));
            sortedLineFeatures.addFirst(lineFeature);
        }

        if (boundingBuilder != null) {
            boundingBuilder.include(new LatLng(locations.getLatitude(i), locations.getLongitude(i)));
        }
    }

    if (sortedPointFeatures.size() > 0) {
        for (Feature position : sortedPointFeatures) {
            if (!position.getBooleanProperty(IS_POI)) {
                position.addStringProperty(LAST_POSITION_ICON, contactMapMetadata.getMarkerLastPositon());
                position.addStringProperty(LAST_POSITION_LABEL, contactMapMetadata.getDisplayName());
                position.removeProperty(MARKER_ICON);
                position.addBooleanProperty(LAST_LOCATION, true);
                lastPositions.put(contactId, position);
                break;
            }
        }
    }

    featureCollections.put(contactMapMetadata.getMarkerFeatureCollection(), sortedPointFeatures);
    featureCollections.put(contactMapMetadata.getLineFeatureCollection(), sortedLineFeatures);
}
 
Example 19
Source File: Node.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
/** Assumes this is NOT a graph with cycles. Non-recursive to avoid stack overflows. */
final void setRoot() {
	// Works, but can be done in one pass TODO
	//
	// Find first the list of nodes from this node to the current root
	// and then proceed in reverse direction!

	final LinkedList<Node<T>> path = new LinkedList<Node<T>>();
	path.add(this);
	Node<T> parent = this.parent;
	while (null != parent) {
		path.addFirst(parent);
		parent = parent.parent;
	}
	Node<T> newchild = path.removeFirst();
	for (final Node<T> nd : path) {
		// Made nd the parent of newchild (was the opposite)
		// 1 - Find out the confidence of the edge to the child node:
		byte conf = MAX_EDGE_CONFIDENCE;
		for (int i=0; i<newchild.children.length; i++) {
			if (nd == newchild.children[i]) {
				conf = newchild.children[i].confidence;
				break;
			}
		}
		// 2 - Remove the child node from the parent's child list
		newchild.remove(nd);
		// 3 - Reverse: add newchild to nd (newchild was parent of nd)
		newchild.parent = null;
		nd.add(newchild, conf);
		// 4 - Prepare next step
		newchild = nd;
	}
	// As root:
	this.parent = null;

	// TODO Below, it should work, but it doesn't (?)
	// It results in all touched nodes not having a parent (all appear as 'S')
	/*

	Node child = this;
	Node parent = this.parent;
	while (null != parent) {
		// 1 - Find out the confidence of the edge to the child node:
		byte conf = MAX_EDGE_CONFIDENCE;
		for (int i=0; i<parent.children.length; i++) {
			if (child == parent.children[i]) {
				conf = parent.children[i].confidence;
				break;
			}
		}
		// 2 - Remove the child node from the parent's child list
		parent.remove(child);
		// 3 - Cache the parent's parent, since it will be overwriten in the next step
		Node pp = parent.parent;
		// 4 - Add the parent as a child of the child, with the same edge confidence
		parent.parent = null; // so it won't be refused
		child.add(parent, conf);
		// 5 - prepare next step
		child = parent;
		parent = pp;
	}
	// Make this node the root node
	this.parent = null;
	*/
}
 
Example 20
Source File: TestRecoveryHdfs.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private void addDocs(int nDocs, int start, LinkedList<Long> versions) throws Exception {
  for (int i=0; i<nDocs; i++) {
    versions.addFirst( addAndGetVersion( sdoc("id",Integer.toString(start + nDocs)) , null) );
  }
}