@Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { /* * TODO(cpovirk): it would be nice to create an input Map and use * the copy constructor here and in the other tests */ return populate(new TreeMap<String, String>(), entries); } })
private void setSegmentSignature(final DataSegment segment, final SegmentMetadataHolder segmentMetadataHolder) { synchronized (lock) { TreeMap<DataSegment, SegmentMetadataHolder> dataSourceSegments = segmentMetadataInfo.computeIfAbsent( segment.getDataSource(), x -> new TreeMap<>(SEGMENT_ORDER) ); if (dataSourceSegments.put(segment, segmentMetadataHolder) == null) { totalSegments++; } } }
private Nature(String name) { if (idMap == null) idMap = new TreeMap<String, Integer>(); assert !idMap.containsKey(name); this.name = name; ordinal = idMap.size(); idMap.put(name, ordinal); Nature[] extended = new Nature[idMap.size()]; if (values != null) System.arraycopy(values, 0, extended, 0, values.length); extended[ordinal] = this; values = extended; }
/** * Splits the range set at the given timestamp (if it hasn't been split yet) */ private void splitAt(long t) { if (data.containsKey(t)) return; // already split at this timestamp SortedMap<Long, int[]> head = data.headMap(t); int v = head.isEmpty() ? 0 : data.get(head.lastKey())[0]; data.put(t, new int[]{v}); }
/** * 克隆一个状态<br> * Constructs an MDAGNode possessing the same accept state status and outgoing transitions as another. * @param node the MDAGNode possessing the accept state status and * outgoing transitions that the to-be-created MDAGNode is to take on */ private MDAGNode(MDAGNode node) { isAcceptNode = node.isAcceptNode; outgoingTransitionTreeMap = new TreeMap<Character, MDAGNode>(node.outgoingTransitionTreeMap); //Loop through the nodes in this node's outgoing _transition set, incrementing the number of //incoming transitions of each by 1 (to account for this newly created node's outgoing transitions) for(Entry<Character, MDAGNode> transitionKeyValuePair : outgoingTransitionTreeMap.entrySet()) transitionKeyValuePair.getValue().incomingTransitionCount++; ///// }
private static void addKeyword(TreeMap<String, String> patternMap, String keyword) { patternMap.put(keyword, keyword); } static
static void combineReverseChain(TreeMap<String, String> t2s, TreeMap<String, String> tw2t, boolean convert) { for (Map.Entry<String, String> entry : tw2t.entrySet()) { String tw = entry.getKey(); String s = t2s.get(entry.getValue()); if (s == null) s = convert ? CharTable.convert(entry.getValue()) : entry.getValue(); t2s.put(tw, s); } }
public void testTreeMapNonGeneric() { TreeMap<LegacyComparable, Integer> map = Maps.newTreeMap(); assertEquals(Collections.emptyMap(), map); map.put(new LegacyComparable("foo"), 1); map.put(new LegacyComparable("bar"), 2); assertThat(map.keySet()) .containsExactly(new LegacyComparable("bar"), new LegacyComparable("foo")) .inOrder(); assertThat(map.values()).containsExactly(2, 1).inOrder(); assertNull(map.comparator()); }
@Override public Double get(Object key) { Double v = super.get(key); if (v == null) return 0.; return v; }
/** * {@inheritDoc} */ public int enter() { return instrumentedMethod.getStackSize() + exitType.getStackSize().getSize() + StackSize.of(namedTypes.values()); }
/** * 本状态的目标状态们的入度减一 * Decrements (by 1) the incoming _transition counts of all of the nodes * that are targets of outgoing transitions from this node. */ public void decrementTargetIncomingTransitionCounts() { for(Entry<Character, MDAGNode> transitionKeyValuePair: outgoingTransitionTreeMap.entrySet()) transitionKeyValuePair.getValue().incomingTransitionCount--; }
public static String toQueryString(Map<String, String> ps) { StringBuilder buf = new StringBuilder(); if (ps != null && ps.size() > 0) { for (Map.Entry<String, String> entry : new TreeMap<String, String>(ps).entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if (isNoneEmpty(key, value)) { if (buf.length() > 0) { buf.append("&"); } buf.append(key); buf.append("="); buf.append(value); } } } return buf.toString(); }
/** * 建立一条边(起点是自己) * @param letter 边上的字符串 * @param newTargetNode 边的重点 * @return 终点 */ public MDAGNode addOutgoingTransition(char letter, MDAGNode newTargetNode) { newTargetNode.incomingTransitionCount++; outgoingTransitionTreeMap.put(letter, newTargetNode); return newTargetNode; }
@Override public void merge(Accumulator<Integer, TreeMap<Integer, Integer>> other) { // Merge the values into this map for (Map.Entry<Integer, Integer> entryFromOther : other.getLocalValue().entrySet()) { Integer ownValue = this.treeMap.get(entryFromOther.getKey()); if (ownValue == null) { this.treeMap.put(entryFromOther.getKey(), entryFromOther.getValue()); } else { this.treeMap.put(entryFromOther.getKey(), entryFromOther.getValue() + ownValue); } } }
public void testTreeMapDerived() { TreeMap<Derived, Integer> map = Maps.newTreeMap(); assertEquals(Collections.emptyMap(), map); map.put(new Derived("foo"), 1); map.put(new Derived("bar"), 2); assertThat(map.keySet()).containsExactly(new Derived("bar"), new Derived("foo")).inOrder(); assertThat(map.values()).containsExactly(2, 1).inOrder(); assertNull(map.comparator()); }