当前位置: 首页>>代码示例>>Java>>正文


Java SortedMap.lastKey方法代码示例

本文整理汇总了Java中java.util.SortedMap.lastKey方法的典型用法代码示例。如果您正苦于以下问题:Java SortedMap.lastKey方法的具体用法?Java SortedMap.lastKey怎么用?Java SortedMap.lastKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.SortedMap的用法示例。


在下文中一共展示了SortedMap.lastKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReadAToolbar

import java.util.SortedMap; //导入方法依赖的package包/类
public void testReadAToolbar() throws Exception {
    InputStream is = getClass().getResourceAsStream("NB_PROF634066243");
    SortedMap<Integer,InputGesture> expectedGestures = new TreeMap<Integer,InputGesture>();
    expectedGestures.put(62, InputGesture.TOOLBAR);
    expectedGestures.put(63, InputGesture.MENU);
    TestHandler records = new TestHandler(is);
    for (int cnt = 0;; cnt++) {
        LOG.log(Level.INFO, "Reading {0}th record", cnt);
        LogRecord r = records.read();
        if (r == null) {
            break;
        }
        if (r.getSequenceNumber() > expectedGestures.lastKey()) {
            break;
        }
        LOG.log(Level.INFO, "Read {0}th record, seq {1}", new Object[] { cnt, r.getSequenceNumber() });

        InputGesture g = InputGesture.valueOf(r);
        InputGesture exp = expectedGestures.get((int)r.getSequenceNumber());
        assertEquals(cnt + ": For: " + r.getSequenceNumber() + " txt:\n`"+ r.getMessage() +
            "\nkey: " + r.getResourceBundleName()
            , exp, g);
    }
    is.close();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:InputGestureTest.java

示例2: getPreProvisioningLsp

import java.util.SortedMap; //导入方法依赖的package包/类
public static RsvpLspDto getPreProvisioningLsp(RsvpLspDto lsp) {
    if (lsp == null) {
        return null;
    }

    try {
        NaefDtoFacade dtofacade = InventoryConnector.getInstance().getDtoFacade();
        SortedMap<TransactionId.W, DateTime> enabledTimeHistory
                = dtofacade.getAttributeHistory(DtoUtil.getMvoId(lsp), ATTR.TASK_ENABLED_TIME);
        TransactionId.W lastProvisioningVersion
                = enabledTimeHistory.size() == 0
                ? null
                : enabledTimeHistory.lastKey();
        if (lastProvisioningVersion == null) {
            return null;
        }

        TransactionId.W tickBefore = new TransactionId.W(lastProvisioningVersion.serial - 1);
        RsvpLspDto oldVersionLsp
                = (RsvpLspDto) dtofacade.getMvoDto(DtoUtil.getMvoId(lsp), tickBefore);
        return oldVersionLsp;
    } catch (Exception e) {
        throw ExceptionUtils.throwAsRuntime(e);
    }
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:26,代码来源:RsvpLspExtUtil.java

示例3: printFrameSizeHistogram

import java.util.SortedMap; //导入方法依赖的package包/类
private static void printFrameSizeHistogram(List<Integer> frameSizes) {
	final int step = 1000;
	SortedMap<Integer,Integer> frameSizeCounts = new TreeMap<>();
	int maxKeyLen = 0;
	for (int fs : frameSizes) {
		int key = (int)Math.round((double)fs / step);
		maxKeyLen = Math.max(Integer.toString(key * step).length(), maxKeyLen);
		if (!frameSizeCounts.containsKey(key))
			frameSizeCounts.put(key, 0);
		frameSizeCounts.put(key, frameSizeCounts.get(key) + 1);
	}
	for (int i = frameSizeCounts.firstKey(); i < frameSizeCounts.lastKey(); i++) {
		if (!frameSizeCounts.containsKey(i))
			frameSizeCounts.put(i, 0);
	}
	List<String> frameSizeLabels = new ArrayList<>();
	List<Double> frameSizeValues = new ArrayList<>();
	for (Map.Entry<Integer,Integer> entry : frameSizeCounts.entrySet()) {
		frameSizeLabels.add(String.format("%" + maxKeyLen + "d", entry.getKey() * step));
		frameSizeValues.add((double)entry.getValue());
	}
	printNormalizedBarGraph("Frame sizes (bytes)", frameSizeLabels, frameSizeValues);
}
 
开发者ID:nayuki,项目名称:FLAC-library-Java,代码行数:24,代码来源:ShowFlacFileStats.java

示例4: testReadALogAndTestInputGestures

import java.util.SortedMap; //导入方法依赖的package包/类
public void testReadALogAndTestInputGestures() throws Exception {
    InputStream is = getClass().getResourceAsStream("NB1216449736.0");
    SortedMap<Integer,InputGesture> expectedGestures = new TreeMap<Integer,InputGesture>();
    expectedGestures.put(35, InputGesture.MENU);
    expectedGestures.put(59, InputGesture.KEYBOARD);
    expectedGestures.put(66, InputGesture.MENU);
    expectedGestures.put(80, InputGesture.MENU);
    expectedGestures.put(81, InputGesture.MENU);
    expectedGestures.put(177, InputGesture.KEYBOARD);
    expectedGestures.put(197, InputGesture.KEYBOARD);
    expectedGestures.put(205, InputGesture.MENU);
    TestHandler records = new TestHandler(is);
    for (int cnt = 0;; cnt++) {
        LOG.log(Level.INFO, "Reading {0}th record", cnt);
        LogRecord r = records.read();
        if (r == null) {
            break;
        }
        if (r.getSequenceNumber() > expectedGestures.lastKey()) {
            break;
        }
        LOG.log(Level.INFO, "Read {0}th record, seq {1}", new Object[] { cnt, r.getSequenceNumber() });

        InputGesture g = InputGesture.valueOf(r);
        InputGesture exp = expectedGestures.get((int)r.getSequenceNumber());
        assertEquals(cnt + ": For: " + r.getSequenceNumber() + " txt:\n`"+ r.getMessage() +
            "\nkey: " + r.getResourceBundleName()
            , exp, g);
    }
    is.close();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:InputGestureTest.java

示例5: lastKey

import java.util.SortedMap; //导入方法依赖的package包/类
@Override public K lastKey() {
  SortedMap<K, V> headMap = sortedMap();
  while (true) {
    // correctly throws NoSuchElementException when filtered map is empty.
    K key = headMap.lastKey();
    if (apply(key, unfiltered.get(key))) {
      return key;
    }
    headMap = sortedMap().headMap(key);
  }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:12,代码来源:Maps.java

示例6: addAbundanceOptionalColumn

import java.util.SortedMap; //导入方法依赖的package包/类
public String addAbundanceOptionalColumn(StudyVariable studyVariable, String order) {
    SortedMap<String, MZTabColumn> columns = AbundanceColumn.createOptionalColumns(section, studyVariable, order);
    abundanceColumnMapping.putAll(columns);
    optionalColumnMapping.putAll(columns);
    columnMapping.putAll(columns);
    return columns.lastKey();
}
 
开发者ID:nilshoffmann,项目名称:jmzTab-m,代码行数:8,代码来源:MZTabColumnFactory.java

示例7: lastKey

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public K lastKey() {
  SortedMap<K, V> headMap = sortedMap();
  while (true) {
    // correctly throws NoSuchElementException when filtered map is empty.
    K key = headMap.lastKey();
    if (apply(key, unfiltered.get(key))) {
      return key;
    }
    headMap = sortedMap().headMap(key);
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:Maps.java

示例8: removeMaxFromReplica

import java.util.SortedMap; //导入方法依赖的package包/类
private static void removeMaxFromReplica(
    SortedMap<Integer, AtomicInteger> replica,
    int maxValue) {
  Integer replicatedMaxValue = replica.lastKey();
  assertTrue("maxValue is incorrect", replicatedMaxValue == maxValue);
  removeFromReplica(replica, replicatedMaxValue);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:MinMaxPriorityQueueTest.java

示例9: floor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Return the largest key in the table <= k.
 */ 
public Key floor(Key k) {
    if (st.containsKey(k)) return k;

    // does not include key if present (!)
    SortedMap<Key, Value> head = st.headMap(k);
    if (head.isEmpty()) return null;
    else return head.lastKey();
}
 
开发者ID:wz12406,项目名称:accumulate,代码行数:12,代码来源:ST.java

示例10: getRange

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Returns submap of x and y values according to the given start and end
 * 
 * @param start start x value
 * @param stop stop x value
 * @param beforeAfterPoints if the points before and after the first and last
 *          visible ones must be displayed
 * @return a submap of x and y values
 */
public synchronized SortedMap<Double, Double> getRange(double start, double stop,
    boolean beforeAfterPoints) {
  if (beforeAfterPoints) {
    // we need to add one point before the start and one point after the end
    // (if
    // there are any)
    // to ensure that line doesn't end before the end of the screen

    // this would be simply: start = mXY.lowerKey(start) but NavigableMap is
    // available since API 9
    SortedMap<Double, Double> headMap = mXY.headMap(start);
    if (!headMap.isEmpty()) {
      start = headMap.lastKey();
    }

    // this would be simply: end = mXY.higherKey(end) but NavigableMap is
    // available since API 9
    // so we have to do this hack in order to support older versions
    SortedMap<Double, Double> tailMap = mXY.tailMap(stop);
    if (!tailMap.isEmpty()) {
      Iterator<Double> tailIterator = tailMap.keySet().iterator();
      Double next = tailIterator.next();
      if (tailIterator.hasNext()) {
        stop = tailIterator.next();
      } else {
        stop += next;
      }
    }
  }
  return mXY.subMap(start, stop);
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:41,代码来源:XYSeries.java

示例11: addEdge

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Add an edge to this graph.
 * 
 * @param timestamp
 * @param edgeName
 * @param source
 * @param dest
 * @param isFromPattern
 */
public void addEdge(long timestamp, String edgeName, String state, String source, String dest,
    boolean isFromPattern) {

  Vertex destVertex = new Vertex(this, dest, state, timestamp);
  SortedMap<Long, Vertex> map = this.indexedVertices.get(dest);
  if (map == null) {
    map = new TreeMap<Long, Vertex>();
    this.indexedVertices.put(dest, map);
  }

  // If this edge is being added by a pattern event, only
  // add the edge if the destination changes state as a result
  // of this edge. This cuts down on noise in the graph.
  if (isFromPattern) {
    SortedMap<Long, Vertex> headMap = map.headMap(timestamp);
    if (headMap != null && !headMap.isEmpty()) {
      Long previousKey = headMap.lastKey();
      Vertex previousVertex = headMap.get(previousKey);
      if (previousVertex.getState().equals(state)) {
        return;
      }
    } else {
      // Super hack here. Don't add a transition from the non existent state to
      // the destroyed state in a lifeline.
      if (state.equals("destroyed")) {
        return;
      }
    }
  }
  map.put(timestamp, destVertex);

  edges.add(new Edge(this, timestamp, edgeName, source, destVertex));
}
 
开发者ID:ampool,项目名称:monarch,代码行数:43,代码来源:Graph.java

示例12: previousKey

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public K previousKey(final K key) {
    if (isEmpty()) {
        return null;
    }
    if (normalMap instanceof OrderedMap) {
        return ((OrderedMap<K, V>) normalMap).previousKey(key);
    }
    final SortedMap<K, V> sm = (SortedMap<K, V>) normalMap;
    final SortedMap<K, V> hm = sm.headMap(key);
    if (hm.isEmpty()) {
        return null;
    }
    return hm.lastKey();
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:16,代码来源:DualTreeBidiMap.java

示例13: validate

import java.util.SortedMap; //导入方法依赖的package包/类
static Map<String, Object> validate(int version, Map<String, TreeMap<Integer, SettingsDescription>> settings,
        Map<String, String> importedSettings, boolean useDefaultValues) {

    Map<String, Object> validatedSettings = new HashMap<>();
    for (Map.Entry<String, TreeMap<Integer, SettingsDescription>> versionedSetting : settings.entrySet()) {

        // Get the setting description with the highest version lower than or equal to the
        // supplied content version.
        TreeMap<Integer, SettingsDescription> versions = versionedSetting.getValue();
        SortedMap<Integer, SettingsDescription> headMap = versions.headMap(version + 1);

        // Skip this setting if it was introduced after 'version'
        if (headMap.isEmpty()) {
            continue;
        }

        Integer settingVersion = headMap.lastKey();
        SettingsDescription desc = versions.get(settingVersion);

        // Skip this setting if it is no longer used in 'version'
        if (desc == null) {
            continue;
        }

        String key = versionedSetting.getKey();

        boolean useDefaultValue;
        if (!importedSettings.containsKey(key)) {
            Timber.v("Key \"%s\" wasn't found in the imported file.%s",
                    key,
                    (useDefaultValues) ? " Using default value." : "");

            useDefaultValue = useDefaultValues;
        } else {
            String prettyValue = importedSettings.get(key);
            try {
                Object internalValue = desc.fromPrettyString(prettyValue);
                validatedSettings.put(key, internalValue);
                useDefaultValue = false;
            } catch (InvalidSettingValueException e) {
                Timber.v("Key \"%s\" has invalid value \"%s\" in imported file. %s",
                        key,
                        prettyValue,
                        (useDefaultValues) ? "Using default value." : "Skipping.");

                useDefaultValue = useDefaultValues;
            }
        }

        if (useDefaultValue) {
            Object defaultValue = desc.getDefaultValue();
            validatedSettings.put(key, defaultValue);
        }
    }

    return validatedSettings;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:58,代码来源:Settings.java

示例14: getImage

import java.util.SortedMap; //导入方法依赖的package包/类
public BufferedImage getImage(SortedMap<Integer, String> map) throws MapIsNullException {
    if (map == null) {
        throw new MapIsNullException();
    }
    BufferedImage bImg = new BufferedImage(BUFFERED_IMAGE_MAX_X, BUFFERED_IMAGE_MAX_Y, BufferedImage.TYPE_INT_ARGB);
    Graphics2D cg = (Graphics2D) bImg.getGraphics();
    cg.setRenderingHint(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    cg.setBackground(Color.WHITE);
    //cg.setStroke(new BasicStroke(2));
    cg.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    int min = map.firstKey();
    int max = map.lastKey();
    int fontSize = cg.getFont().getSize() / 2;
    cg.fillRect(0, 0, BUFFERED_IMAGE_MAX_X, BUFFERED_IMAGE_MAX_Y);
    cg.setPaint(Color.BLACK);
    Map<String, IntPair> descPosMap = new HashMap();
    Map<String, Color> descColMap = new HashMap();
    for (int i = max - min; i >= 0; i--) {
        int num_bit = i + min;
        String numString = Integer.toString(num_bit);
        if (!map.containsKey(num_bit)) {
            cg.setPaint(Color.lightGray);
            cg.fillRect(PADDING + i * SQUARE_FACTOR_X * fontSize, PADDING, SQUARE_FACTOR_X * fontSize, SQUARE_FACTOR_Y * fontSize);
            cg.setPaint(Color.BLACK);
        } else {
            String description = map.get(num_bit);
            IntPair stringPosition;
            int descriptionExists = 0;
            if (description.length() > 0) {
                if (!descPosMap.keySet().contains(description)) {
                    stringPosition = new IntPair(PADDING + i * SQUARE_FACTOR_X * fontSize, 30 + SQUARE_FACTOR_Y * fontSize + descPosMap.size() * 3 * fontSize);
                    descPosMap.put(description, stringPosition);
                    cg.setColor(Color.WHITE);
                    cg.fillRect(stringPosition.getX(), stringPosition.getY() - fontSize, description.length() * fontSize, 2 * fontSize);
                    Color descColor = palette.getColor((double) i / (max - min));
                    descColMap.put(description, descColor);
                    cg.setColor(descColor);
                    cg.drawString(description, stringPosition.getX(), stringPosition.getY() + fontSize);
                } else {
                    descriptionExists = 1;
                    stringPosition = descPosMap.get(description);
                    cg.setColor(descColMap.get(description));
                    cg.drawLine(
                            stringPosition.getX() + fontSize,
                            stringPosition.getY() - fontSize * 2,
                            PADDING + i * SQUARE_FACTOR_X * fontSize + fontSize,
                            stringPosition.getY() - fontSize * 2
                    );
                }
                cg.drawLine(
                        PADDING + i * SQUARE_FACTOR_X * fontSize + fontSize,
                        stringPosition.getY() - fontSize * (1 + descriptionExists),
                        PADDING + i * SQUARE_FACTOR_X * fontSize + fontSize,
                        PADDING + SQUARE_FACTOR_Y * fontSize
                );
            }
        }
        cg.drawRect(PADDING + i * SQUARE_FACTOR_X * fontSize, PADDING, SQUARE_FACTOR_X * fontSize, SQUARE_FACTOR_Y * fontSize);
        cg.drawString(numString, PADDING + fontSize + i * SQUARE_FACTOR_X * fontSize, PADDING + 3 * fontSize);
        cg.setColor(Color.BLACK);
    }
    BufferedImage returned_bImg = bImg.getSubimage(
            0,
            0,
            2 * BUFFERED_IMAGE_PADDING + (max - min + 1) * SQUARE_FACTOR_X * fontSize + map.get(map.lastKey()).length() * fontSize,
            DRAW_BOARD_Y);

    return returned_bImg;
}
 
开发者ID:fusiled,项目名称:bitbox,代码行数:72,代码来源:PainterLogic.java

示例15: previousKey

import java.util.SortedMap; //导入方法依赖的package包/类
public K previousKey(final K key) {
    final SortedMap<K, V> headMap = headMap(key);
    return headMap.isEmpty() ? null : headMap.lastKey();
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:5,代码来源:AbstractSortedMapDecorator.java


注:本文中的java.util.SortedMap.lastKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。