Java Code Examples for java.util.TreeMap#size()

The following examples show how to use java.util.TreeMap#size() . 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: BreadCrumbUI.java    From pumpernickel with MIT License 6 votes vote down vote up
/**
 * Return the labels that exactly correspond to <code>jbc.getPath()</code>
 * in the analogous order.
 */
protected static JLabel[] getCrumbs(JBreadCrumb<?> jbc) {
	TreeMap<Integer, JLabel> map = new TreeMap<Integer, JLabel>();
	for (int a = 0; a < jbc.getComponentCount(); a++) {
		Component c = jbc.getComponent(a);
		if (c instanceof JLabel) {
			JLabel label = (JLabel) c;
			Integer i = (Integer) label
					.getClientProperty(PATH_NODE_INDEX_KEY);
			if (i != null) {
				map.put(i, label);
			}
		}
	}
	JLabel[] array = new JLabel[map.size()];
	int ctr = 0;
	for (Integer key : map.keySet()) {
		array[ctr++] = map.get(key);
	}
	return array;
}
 
Example 2
Source File: RankCalculator.java    From ACManager with GNU General Public License v3.0 6 votes vote down vote up
private boolean[] teatWaClear(TeamRanking ranking, int capacity) {
    List<PbStatus> list = ranking.getPbStatus();
    boolean[] ans = new boolean[list.size()];
    TreeMap<PbStatus, Integer> ac = new TreeMap<>();
    int waCnt = 0;
    for (int i = 0; i < list.size(); ++i) {
        if(list.get(i).isSolved()) {
            waCnt += list.get(i).getWaCount();
            if(list.get(i).getWaCount() == 0) //1A奖励
                waCnt -= 1;
            ac.put(list.get(i), i);
        }
    }
    while(ac.size() >= 2 && waCnt > ac.size() * capacity) {
        Map.Entry<PbStatus, Integer> entry = ac.lastEntry();
        ans[entry.getValue()] = true;
        waCnt -= entry.getKey().getWaCount();
        ac.remove(entry.getKey());
    }
    return ans;
}
 
Example 3
Source File: EnvironmentVariablesTableModel.java    From keystore-explorer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Load the EnvironmentVariablesTableModel with Environment Variables.
 */
public void load() {
	TreeMap<String, String> envs = new TreeMap<>(new EnvironmentVariableComparator());
	envs.putAll(System.getenv());

	data = new String[envs.size()][2];

	int i = 0;
	for (Iterator<Entry<String, String>> itrSorted = envs.entrySet().iterator(); itrSorted.hasNext(); i++) {
		Map.Entry<String, String> property = itrSorted.next();

		data[i][0] = property.getKey();
		data[i][1] = property.getValue();
	}

	fireTableDataChanged();
}
 
Example 4
Source File: TagAdaptiveRandomization.java    From ctsms with GNU Lesser General Public License v2.1 6 votes vote down vote up
private InputFieldSelectionSetValue getRandomValue(Trial trial, TreeMap<InputFieldSelectionSetValue, Double> pMap) throws Exception {
	if (pMap.size() > 0) {
		double r = getRandom(trial).nextDouble();
		Iterator<Entry<InputFieldSelectionSetValue, Double>> it = pMap.entrySet().iterator();
		double pFrom = 0.0d;
		double pTo;
		while (it.hasNext()) {
			Entry<InputFieldSelectionSetValue, Double> p = it.next();
			pTo = pFrom + p.getValue();
			if (r >= pFrom && r < pTo) {
				return p.getKey();
			}
			pFrom = pTo;
		}
	}
	return null;
}
 
Example 5
Source File: TableNameService.java    From star-zone with Apache License 2.0 6 votes vote down vote up
public String getTableName(String name, long id){
    if (StringUtils.isEmpty(name) || id < 1) {
        return null;
    }
    String tableName = null;
    TreeMap<Long, String> shardMap = null;
    switch (name) {
        case ShardedTableName.ORDER:
            shardMap = CustomSingleton.getInstance().getOrderShardMap();
            break;
        case ShardedTableName.MOMENT_LIKE:
            shardMap = CustomSingleton.getInstance().getMomentLikeShardMap();
            break;
    }

    if (shardMap != null || shardMap.size() > 0){
        String realTableName = ShardUtil.doGetTableName(shardMap, id+"");
        log.info("realTableName={}", realTableName);
        return realTableName;
    }
    return null;
}
 
Example 6
Source File: Solution.java    From codekata with MIT License 6 votes vote down vote up
public int deleteAndEarn(int[] nums) {
    TreeMap<Integer, Integer> map = new TreeMap<>();
    for (int num : nums) {
        map.put(num, map.getOrDefault(num, 0) + num);
    }

    int pick = 0, drop = 0, item = 0;
    while (map.size() != 0) {
        int nextItem = map.firstKey(), v = map.remove(nextItem);
        int nextPick = nextItem == item + 1 ? drop + v : Math.max(drop, pick) + v, nextDrop = Math.max(drop, pick);
        item = nextItem;
        drop = nextDrop;
        pick = nextPick;
    }
    return Math.max(pick, drop);
}
 
Example 7
Source File: PushdownLargeFieldedListsVisitor.java    From datawave with Apache License 2.0 6 votes vote down vote up
private List<List<Map.Entry<Range,JexlNode>>> batchRanges(TreeMap<Range,JexlNode> ranges, int numBatches) {
    List<List<Map.Entry<Range,JexlNode>>> batchedRanges = new ArrayList<>();
    double rangesPerBatch = ((double) ranges.size()) / ((double) numBatches);
    double total = rangesPerBatch;
    List<Map.Entry<Range,JexlNode>> rangeList = new ArrayList<>();
    int rangeIdx = 0;
    for (Map.Entry<Range,JexlNode> range : ranges.entrySet()) {
        if (rangeIdx++ >= total) {
            total += rangesPerBatch;
            batchedRanges.add(rangeList);
            rangeList = new ArrayList<>();
        }
        rangeList.add(range);
    }
    
    if (!rangeList.isEmpty())
        batchedRanges.add(rangeList);
    
    return batchedRanges;
}
 
Example 8
Source File: TableNameService.java    From star-zone with Apache License 2.0 6 votes vote down vote up
public String getTableName(String name, long id){
    if (StringUtils.isEmpty(name) || id < 1) {
        return null;
    }
    String tableName = null;
    TreeMap<Long, String> shardMap = null;
    switch (name) {
        case ShardedTableName.ORDER:
            shardMap = CustomSingleton.getInstance().getOrderShardMap();
            break;
        case ShardedTableName.MOMENT_LIKE:
            shardMap = CustomSingleton.getInstance().getMomentLikeShardMap();
            break;
    }

    if (shardMap != null || shardMap.size() > 0){
        String realTableName = ShardUtil.doGetTableName(shardMap, id+"");
        log.info("realTableName={}", realTableName);
        return realTableName;
    }
    return null;
}
 
Example 9
Source File: LearningController.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
    * Create a map of the reports (in ScribeSessionDTO format) for all the other groups/sessions, where the key is the
    * group/session name. The code ensures that the session name is unique, adding the session id if necessary. It will
    * only include the finalized reports.
    */
   private void setupOtherGroupReportDTO(HttpServletRequest request, ScribeSession scribeSession,
    ScribeUser scribeUser) {
TreeMap<String, ScribeSessionDTO> otherScribeSessions = ScribeUtils.getReportDTOs(scribeSession);
if (otherScribeSessions.size() > 0) {
    request.setAttribute("otherScribeSessions", otherScribeSessions.values());
}
   }
 
Example 10
Source File: SnmpCachedData.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a new instance of SnmpCachedData. Instances are
 * immutable.
 * @param lastUpdated Time stamp as returned by
 *        {@link System#currentTimeMillis System.currentTimeMillis()}
 * @param indexMap The table indexed table data, sorted in ascending
 *                 order by {@link #oidComparator}. The keys must be
 *                 instances of {@link SnmpOid}.
 **/
public SnmpCachedData(long lastUpdated, TreeMap<SnmpOid, Object> indexMap,
                      boolean b) {

    final int size = indexMap.size();
    this.lastUpdated = lastUpdated;
    this.indexes     = new SnmpOid[size];
    this.datas       = new Object[size];

    if(b) {
        indexMap.keySet().toArray(this.indexes);
        indexMap.values().toArray(this.datas);
    } else
        indexMap.values().toArray(this.datas);
}
 
Example 11
Source File: NativeEnvironmentSelectionDialog.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IContentProvider getContentProvider() {
	return new IStructuredContentProvider() {
		@Override
		public Object[] getElements(Object inputElement) {
			EnvironmentVariable[] elements = null;
			if (inputElement instanceof HashMap) {
				Comparator<Object> comparator = new Comparator<Object>() {
					@Override
					public int compare(Object o1, Object o2) {
						String s1 = (String) o1;
						String s2 = (String) o2;
						return s1.compareTo(s2);
					}
				};
				TreeMap<Object, Object> envVars = new TreeMap<Object, Object>(comparator);
				envVars.putAll((Map<?, ?>) inputElement);
				elements = new EnvironmentVariable[envVars.size()];
				int index = 0;
				for (Iterator<Object> iterator = envVars.keySet().iterator(); iterator.hasNext(); index++) {
					Object key = iterator.next();
					elements[index] = (EnvironmentVariable) envVars.get(key);
				}
			}
			return elements;
		}
		@Override
		public void dispose() {	
		}
		@Override
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
		}
	};
}
 
Example 12
Source File: TableInfo.java    From FairEmail with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return null if we cannot read the index due to older sqlite implementations.
 */
@Nullable
private static Index readIndex(SupportSQLiteDatabase database, String name, boolean unique) {
    Cursor cursor = database.query("PRAGMA index_xinfo(`" + name + "`)");
    try {
        final int seqnoColumnIndex = cursor.getColumnIndex("seqno");
        final int cidColumnIndex = cursor.getColumnIndex("cid");
        final int nameColumnIndex = cursor.getColumnIndex("name");
        if (seqnoColumnIndex == -1 || cidColumnIndex == -1 || nameColumnIndex == -1) {
            // we cannot read them so better not validate any index.
            return null;
        }
        final TreeMap<Integer, String> results = new TreeMap<>();

        while (cursor.moveToNext()) {
            int cid = cursor.getInt(cidColumnIndex);
            if (cid < 0) {
                // Ignore SQLite row ID
                continue;
            }
            int seq = cursor.getInt(seqnoColumnIndex);
            String columnName = cursor.getString(nameColumnIndex);
            results.put(seq, columnName);
        }
        final List<String> columns = new ArrayList<>(results.size());
        columns.addAll(results.values());
        return new Index(name, unique, columns);
    } finally {
        cursor.close();
    }
}
 
Example 13
Source File: CombineSplitter.java    From PoseidonX with Apache License 2.0 5 votes vote down vote up
private void checkCombineCondition(List<StreamAliasDesc> streams,
 TreeMap<String, PropertyValueExpressionDesc> conditions)
    throws ApplicationBuildException
{
    if (streams.size() != conditions.size())
    {
        ApplicationBuildException exception =
            new ApplicationBuildException(ErrorCode.SEMANTICANALYZE_COMBINE_SIZE, String.valueOf(streams.size()),
                String.valueOf(conditions.size()));
        LOG.error("Stream size not match condition size.", exception);
        throw exception;
    }
}
 
Example 14
Source File: GrammarPacker.java    From joshua with Apache License 2.0 5 votes vote down vote up
/**
 * Add a block of features to the buffer.
 *
 * @param features TreeMap with the features for one rule.
 * @return The index of the resulting data block.
 */
@Override
int add(TreeMap<Integer, Float> features) {
  int data_position = buffer.position();

  // Over-estimate how much room this addition will need: for each
  // feature (ID_SIZE for label, "upper bound" of 4 for the value), plus ID_SIZE for
  // the number of features. If this won't fit, reallocate the buffer.
  int size_estimate = (4 + EncoderConfiguration.ID_SIZE) * features.size()
      + EncoderConfiguration.ID_SIZE;
  if (buffer.capacity() - buffer.position() <= size_estimate)
    reallocate();

  // Write features to buffer.
  idEncoder.write(buffer, features.size());
  for (Integer k : features.descendingKeySet()) {
    float v = features.get(k);
    // Sparse features.
    if (v != 0.0) {
      idEncoder.write(buffer, k);
      encoderConfig.encoder(k).write(buffer, v);
    }
  }
  // Store position the block was written to.
  memoryLookup.add(data_position);
  // Update total size (in bytes).
  totalSize = buffer.position();

  // Return block index.
  return memoryLookup.size() - 1;
}
 
Example 15
Source File: UserAPIController.java    From onboard with Apache License 2.0 5 votes vote down vote up
/**
 * 获取完成的bugs
 * 
 * @param companyId
 * @param userId
 * @param until
 * @return
 */
@RequestMapping(value = "/{companyId}/user/{userId}/completedBugs", method = RequestMethod.GET)
@Interceptors({ CompanyMemberRequired.class, UserChecking.class })
@ResponseBody
public Map<String, Object> viewUserCompletedBugs(@PathVariable int companyId, @PathVariable int userId,
        @RequestParam(value = "until", required = false) @DateTimeFormat(iso = ISO.DATE) Date until) {
    Builder<String, Object> builder = ImmutableMap.builder();
    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    List<Integer> projectList = getProjectListOfCurrentUser(companyId);

    TreeMap<Date, Map<Integer, List<Bug>>> map = bugService.getCompletedBugsGroupByDateByUser(companyId, userId,
            projectList, until, PER_PAGE);
    TreeMap<String, Map<Integer, List<BugDTO>>> mapDTO = makeUserCompletedBugsMapSerilizable(map);
    builder.put("completedBugs", mapDTO);
    Map<Integer, String> projectIdToName = getProjectIdAndNameByCompanyId(companyId);
    builder.put("projectsName", projectIdToName);

    boolean hasNext = false;
    if (map != null && map.size() > 0) {
        Date newUntil = new DateTime(map.firstKey()).withTime(0, 0, 0, 0).plusMillis(-1).toDate();
        TreeMap<Date, Map<Integer, List<Bug>>> nextMap = bugService.getCompletedBugsGroupByDateByUser(companyId,
                userId, projectList, newUntil, PER_PAGE);
        hasNext = nextMap.size() > 0;

        builder.put("nextPage", dtf.print(new DateTime(newUntil)));
    }
    builder.put("hasNext", hasNext);

    return builder.build();
}
 
Example 16
Source File: SunFontManager.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns all fonts installed in this environment.
 */
public Font[] getAllInstalledFonts() {
    if (allFonts == null) {
        loadFonts();
        TreeMap fontMapNames = new TreeMap();
        /* warning: the number of composite fonts could change dynamically
         * if applications are allowed to create them. "allfonts" could
         * then be stale.
         */
        Font2D[] allfonts = getRegisteredFonts();
        for (int i=0; i < allfonts.length; i++) {
            if (!(allfonts[i] instanceof NativeFont)) {
                fontMapNames.put(allfonts[i].getFontName(null),
                                 allfonts[i]);
            }
        }

        String[] platformNames = getFontNamesFromPlatform();
        if (platformNames != null) {
            for (int i=0; i<platformNames.length; i++) {
                if (!isNameForRegisteredFile(platformNames[i])) {
                    fontMapNames.put(platformNames[i], null);
                }
            }
        }

        String[] fontNames = null;
        if (fontMapNames.size() > 0) {
            fontNames = new String[fontMapNames.size()];
            Object [] keyNames = fontMapNames.keySet().toArray();
            for (int i=0; i < keyNames.length; i++) {
                fontNames[i] = (String)keyNames[i];
            }
        }
        Font[] fonts = new Font[fontNames.length];
        for (int i=0; i < fontNames.length; i++) {
            fonts[i] = new Font(fontNames[i], Font.PLAIN, 1);
            Font2D f2d = (Font2D)fontMapNames.get(fontNames[i]);
            if (f2d  != null) {
                FontAccess.getFontAccess().setFont2D(fonts[i], f2d.handle);
            }
        }
        allFonts = fonts;
    }

    Font []copyFonts = new Font[allFonts.length];
    System.arraycopy(allFonts, 0, copyFonts, 0, allFonts.length);
    return copyFonts;
}
 
Example 17
Source File: FileMemorandum.java    From jstarcraft-core with Apache License 2.0 4 votes vote down vote up
@Override
public void checkOut(Instant from, Instant to) {
    // 清空目标目录
    try {
        FileUtils.deleteDirectory(environmentDirectory);
    } catch (IOException ioException) {
    }

    environmentDirectory.mkdirs();

    // 按照日期排序的Map,保证新文件会覆盖旧文件
    final TreeMap<Instant, File> restoreDirectoryMap = new TreeMap<>();
    for (File dayDirectory : memorandumDirectory.listFiles()) {
        if (dayDirectory.isDirectory()) {
            for (File timeDirectory : dayDirectory.listFiles()) {
                if (timeDirectory.isDirectory()) {
                    Instant date = Instant.from(formatter.parse(dayDirectory.getName() + File.separator + timeDirectory.getName()));
                    if (!date.isBefore(from) && !date.isAfter(to)) {
                        restoreDirectoryMap.put(date, timeDirectory);
                    }
                }
            }
        }
    }

    if (restoreDirectoryMap.size() == 0) {
        throw new BerkeleyMemorandumException("不包含恢复目录");
    }

    final File lastBackUpDirectory = restoreDirectoryMap.lastEntry().getValue();
    final File listFile = new File(lastBackUpDirectory, MEMORANDUM_FILE);

    if (!listFile.exists()) {
        throw new BerkeleyMemorandumException("备忘文件不存在");
    }

    // 恢复的文件列表
    final Collection<String> names = new HashSet<String>();

    try (FileInputStream fileInputStream = new FileInputStream(listFile); InputStreamReader dataInputStream = new InputStreamReader(fileInputStream, StringUtility.CHARSET); BufferedReader bufferedReader = new BufferedReader(dataInputStream);) {
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            names.add(line);
        }

        // 恢复目标目录
        for (Entry<Instant, File> keyValue : restoreDirectoryMap.entrySet()) {
            final File restoreDirectory = keyValue.getValue();
            for (File fromFile : restoreDirectory.listFiles()) {
                if (names.contains(fromFile.getName()) && fromFile.isFile()) {
                    final File toFile = new File(environmentDirectory, fromFile.getName());
                    FileUtils.copyFile(fromFile, toFile);
                }
            }
        }
    } catch (Exception exception) {
        throw new BerkeleyMemorandumException("恢复文件失败", exception);
    }
}
 
Example 18
Source File: SunFontManager.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Returns all fonts installed in this environment.
 */
public Font[] getAllInstalledFonts() {
    if (allFonts == null) {
        loadFonts();
        TreeMap fontMapNames = new TreeMap();
        /* warning: the number of composite fonts could change dynamically
         * if applications are allowed to create them. "allfonts" could
         * then be stale.
         */
        Font2D[] allfonts = getRegisteredFonts();
        for (int i=0; i < allfonts.length; i++) {
            if (!(allfonts[i] instanceof NativeFont)) {
                fontMapNames.put(allfonts[i].getFontName(null),
                                 allfonts[i]);
            }
        }

        String[] platformNames = getFontNamesFromPlatform();
        if (platformNames != null) {
            for (int i=0; i<platformNames.length; i++) {
                if (!isNameForRegisteredFile(platformNames[i])) {
                    fontMapNames.put(platformNames[i], null);
                }
            }
        }

        String[] fontNames = null;
        if (fontMapNames.size() > 0) {
            fontNames = new String[fontMapNames.size()];
            Object [] keyNames = fontMapNames.keySet().toArray();
            for (int i=0; i < keyNames.length; i++) {
                fontNames[i] = (String)keyNames[i];
            }
        }
        Font[] fonts = new Font[fontNames.length];
        for (int i=0; i < fontNames.length; i++) {
            fonts[i] = new Font(fontNames[i], Font.PLAIN, 1);
            Font2D f2d = (Font2D)fontMapNames.get(fontNames[i]);
            if (f2d  != null) {
                FontAccess.getFontAccess().setFont2D(fonts[i], f2d.handle);
            }
        }
        allFonts = fonts;
    }

    Font []copyFonts = new Font[allFonts.length];
    System.arraycopy(allFonts, 0, copyFonts, 0, allFonts.length);
    return copyFonts;
}
 
Example 19
Source File: SunFontManager.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get a list of installed fonts in the requested {@link Locale}.
 * The list contains the fonts Family Names.
 * If Locale is null, the default locale is used.
 *
 * @param requestedLocale, if null the default locale is used.
 * @return list of installed fonts in the system.
 */
public String[] getInstalledFontFamilyNames(Locale requestedLocale) {
    if (requestedLocale == null) {
        requestedLocale = Locale.getDefault();
    }
    if (allFamilies != null && lastDefaultLocale != null &&
        requestedLocale.equals(lastDefaultLocale)) {
            String[] copyFamilies = new String[allFamilies.length];
            System.arraycopy(allFamilies, 0, copyFamilies,
                             0, allFamilies.length);
            return copyFamilies;
    }

    TreeMap<String,String> familyNames = new TreeMap<String,String>();
    //  these names are always there and aren't localised
    String str;
    str = Font.SERIF;         familyNames.put(str.toLowerCase(), str);
    str = Font.SANS_SERIF;    familyNames.put(str.toLowerCase(), str);
    str = Font.MONOSPACED;    familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG;        familyNames.put(str.toLowerCase(), str);
    str = Font.DIALOG_INPUT;  familyNames.put(str.toLowerCase(), str);

    /* Platform APIs may be used to get the set of available family
     * names for the current default locale so long as it is the same
     * as the start-up system locale, rather than loading all fonts.
     */
    if (requestedLocale.equals(getSystemStartupLocale()) &&
        getFamilyNamesFromPlatform(familyNames, requestedLocale)) {
        /* Augment platform names with JRE font family names */
        getJREFontFamilyNames(familyNames, requestedLocale);
    } else {
        loadFontFiles();
        Font2D[] physicalfonts = getPhysicalFonts();
        for (int i=0; i < physicalfonts.length; i++) {
            if (!(physicalfonts[i] instanceof NativeFont)) {
                String name =
                    physicalfonts[i].getFamilyName(requestedLocale);
                familyNames.put(name.toLowerCase(requestedLocale), name);
            }
        }
    }

    // Add any native font family names here
    addNativeFontFamilyNames(familyNames, requestedLocale);

    String[] retval =  new String[familyNames.size()];
    Object [] keyNames = familyNames.keySet().toArray();
    for (int i=0; i < keyNames.length; i++) {
        retval[i] = (String)familyNames.get(keyNames[i]);
    }
    if (requestedLocale.equals(Locale.getDefault())) {
        lastDefaultLocale = requestedLocale;
        allFamilies = new String[retval.length];
        System.arraycopy(retval, 0, allFamilies, 0, allFamilies.length);
    }
    return retval;
}
 
Example 20
Source File: RandomVariableDifferentiableAADStochasticNonOptimized.java    From finmath-lib with Apache License 2.0 4 votes vote down vote up
@Override
public Map<Long, RandomVariable> getGradient(final Set<Long> independentIDs) {

	// The map maintaining the derivatives id -> derivative
	final Map<Long, RandomVariable> derivatives = new HashMap<>();

	// Put derivative of this node w.r.t. itself
	derivatives.put(getID(), new RandomVariableFromDoubleArray(1.0));

	// The set maintaining the independents. Note: TreeMap is maintaining a sort on the keys.
	final TreeMap<Long, OperatorTreeNode> independents = new TreeMap<>();
	independents.put(getID(), getOperatorTreeNode());

	while(independents.size() > 0) {
		// Process node with the highest id in independents
		final Map.Entry<Long, OperatorTreeNode> independentEntry = independents.lastEntry();
		final Long id = independentEntry.getKey();
		final OperatorTreeNode independent = independentEntry.getValue();

		// Get arguments of this node and propagate derivative to arguments
		final List<OperatorTreeNode> arguments = independent.arguments;
		if(arguments != null && arguments.size() > 0) {
			independent.propagateDerivativesFromResultToArgument(derivatives);

			// Add all non constant arguments to the list of independents
			for(final OperatorTreeNode argument : arguments) {
				if(argument != null) {
					final Long argumentId = argument.id;
					independents.put(argumentId, argument);
				}
			}

			// Remove id from derivatives - keep only leaf nodes.
			derivatives.remove(id);
		}

		// Done with processing. Remove from map.
		independents.remove(id);
	}

	return derivatives;
}