int getSeparatorCount(Tree right, Tree left) { if (right == null || left == null) { return 0; } int leftHead = ShiftReduceUtils.headIndex(left); int rightHead = ShiftReduceUtils.headIndex(right); Integer nextSeparator = separators.higherKey(leftHead); int count = 0; while (nextSeparator != null && nextSeparator < rightHead) { ++count; nextSeparator = separators.higherKey(nextSeparator); } return count; }
public Long getPositionAtOrAfter(Long position) { if(timeByPosition.isEmpty()) { return null; } if(position==null) { return timeByPosition.firstKey(); } if(timeByPosition.containsKey(position)) { return position; } return timeByPosition.higherKey(position); } }
private String formatAnnotation(int offset, String annotationMsg) { Integer endOffset = annotatations.higherKey(offset); return formatAnnotation(offset, endOffset, annotationMsg); }
private String formatAnnotation(int offset, String annotationMsg) { Integer endOffset = annotatations.higherKey(offset); return formatAnnotation(offset, endOffset, annotationMsg); }
int getSeparatorCount(Tree right, Tree left) { if (right == null || left == null) { return 0; } int leftHead = ShiftReduceUtils.headIndex(left); int rightHead = ShiftReduceUtils.headIndex(right); Integer nextSeparator = separators.higherKey(leftHead); int count = 0; while (nextSeparator != null && nextSeparator < rightHead) { ++count; nextSeparator = separators.higherKey(nextSeparator); } return count; }
private String formatAnnotation(int offset, String annotationMsg) { Integer endOffset = annotatations.higherKey(offset); return formatAnnotation(offset, endOffset, annotationMsg); }
int getSeparatorCount(Tree right, Tree left) { if (right == null || left == null) { return 0; } int leftHead = ShiftReduceUtils.headIndex(left); int rightHead = ShiftReduceUtils.headIndex(right); Integer nextSeparator = separators.higherKey(leftHead); int count = 0; while (nextSeparator != null && nextSeparator < rightHead) { ++count; nextSeparator = separators.higherKey(nextSeparator); } return count; }
private String formatAnnotation(int offset, String annotationMsg) { Integer endOffset = annotatations.higherKey(offset); return formatAnnotation(offset, endOffset, annotationMsg); }
int getSeparatorCount(Tree right, Tree left) { if (right == null || left == null) { return 0; } int leftHead = ShiftReduceUtils.headIndex(left); int rightHead = ShiftReduceUtils.headIndex(right); Integer nextSeparator = separators.higherKey(leftHead); int count = 0; while (nextSeparator != null && nextSeparator < rightHead) { ++count; nextSeparator = separators.higherKey(nextSeparator); } return count; }
public static void main(String[] args) throws Exception { int arrayOne[] = {1, 50, 100, 50, 100, 22, 23, 26}; int arrayTwo[] = {1, 45, 22, 23, 52, 90, 100, 99}; TreeMap<Integer, Integer> map = new TreeMap<Integer, Integer>(); for (int i = 0; i < arrayTwo.length; i++) if (!map.containsKey(arrayTwo[i])) // if you want it to choose the first map.put(arrayTwo[i], i); int arrayThree[] = new int[arrayOne.length]; for (int i = 0; i < arrayThree.length; i++) { int v = arrayOne[i]; Integer h = map.higherKey(v - 1); Integer l = map.lowerKey(v); arrayThree[i] = map.get(l !=null && (h ==null || v - l < h - v) ? l : h); } System.out.println(Arrays.toString(arrayThree)); }
private TreeMap<Comparable, AbstractNode> justInsert(Comparable middleKey, AbstractNode subLeftNode, AbstractNode subRightNode) { TreeMap<Comparable, AbstractNode> newMap = duplicateMap(); // find smallest key greater than middleKey Comparable keyJustAfterMiddleKey = newMap.higherKey(middleKey); newMap.put(keyJustAfterMiddleKey, subRightNode); // this replaces the previous mapping newMap.put(middleKey, subLeftNode); // this adds the new split setSubNodes(newMap); return newMap; }
ValueRange<K,V> lookup( K at ) { if ( endKey != null && endKey.compareTo( at ) <= 0 ) { return new ValueRange<>( null, endValue ); } Map.Entry<K,V> entry = tree.floorEntry( at ); return new ValueRange<>( tree.higherKey( at ), entry != null ? entry.getValue() : null ); }
ValueRange<K,V> lookup( K at ) { if ( endKey != null && endKey.compareTo( at ) <= 0 ) { return new ValueRange<>( null, endValue ); } Map.Entry<K,V> entry = tree.floorEntry( at ); return new ValueRange<>( tree.higherKey( at ), entry != null ? entry.getValue() : null ); }
public String getMatchingEntry(String name) { String key = this.header2ends.ceilingKey(name); if (key == null || !key.startsWith(name)) return null; int position = this.header2ends.get(key) - 1; Integer start = annotations.floorKey(position); // always "_" at start Integer end = annotations.higherKey(position); // exclusive if (start == null) start = 0; if (end == null) end = (int) this.getSize(); while (!isValid(end - 1)) end--; // ensure that the last character is valid (exclusive) return this.getSubsequence(start + 1, end); }
public String getMatchingEntry(long position) { Integer start = annotations.floorKey((int) position); // always "_" at start Integer end = annotations.higherKey((int) position); // exclusive if (start == null) start = 0; if (end == null) end = (int) this.getSize(); while (!isValid(end - 1)) end--; // ensure that the last character is valid (exclusive) return this.getSubsequence(start + 1, end); }
public String getMatchingEntry(long position) { Integer start = annotations.floorKey((int) position); // always "_" at start Integer end = annotations.higherKey((int) position); // exclusive if (start == null) start = 0; if (end == null) end = (int) this.getSize(); while (!isValid(end - 1)) end--; // ensure that the last character is valid (exclusive) return this.getSubsequence(start + 1, end); }
public List<Pair<Integer, Float>> getXIC(int scanNum, float mz, Tolerance tol) { ArrayList<Pair<Integer, Float>> xic = new ArrayList<Pair<Integer, Float>>(); Peak p; // Move down Integer curScanNum = scanNum; while (curScanNum != null && scanNum > 0) { curScanNum = ms1SpecMap.lowerKey(curScanNum); if ((p = getMS1Peak(curScanNum, mz, tol)) != null) xic.add(new Pair<Integer, Float>(curScanNum, p.getIntensity())); else break; } // Move up curScanNum = scanNum; while (curScanNum != null && curScanNum < 100000) { curScanNum = ms1SpecMap.higherKey(curScanNum); if ((p = getMS1Peak(curScanNum, mz, tol)) != null) xic.add(new Pair<Integer, Float>(curScanNum, p.getIntensity())); else break; } Collections.sort(xic, new Pair.PairComparator<Integer, Float>()); return xic; }
curr = null; } else { curr = (CodepointMatchKey) index.higherKey(curr);
curr = null; } else { curr = (CodepointMatchKey) index.higherKey(curr);