/* * Does not recalculate if greedySplits are already cached. */ private void findGreedySplits() { if (greedySplits != null) return; sortSplits(); int nGreedySplits = idg.getIdCount() - 3; greedySplits = new Vector<Split>(nGreedySplits); greedySplitIndex = new Vector<Integer>(nGreedySplits); for (int i = 0; i < sortedSplits.size() && greedySplits.size() < nGreedySplits; i++) { String splitStr = sortedSplits.elementAt(i); Split split = splits.get(splitStr); if (split.compatible(greedySplits)) { greedySplits.add(split); greedySplitIndex.add(i); } } }
/* * Will redo the sort-by-frequency even if it has already been done. * Clears greedySplits. */ private void resortSplits() { sortedSplits = new Vector<String>(counts.size()); // to be sorted by frequency for (String splitStr : counts.keySet()) { sortedSplits.add(splitStr); } shuffler.shuffle(sortedSplits); Collections.sort(sortedSplits, frequencyComparator); greedySplits = null; greedySplitIndex = null; }