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


Java SortedMap.containsKey方法代码示例

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


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

示例1: get

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Get all of the ParameterMapping for this StmtParameter, regardless of the catalog_stmt_index
 * @param catalog_stmt
 * @param catalog_stmt_param
 * @return
 */
protected Collection<ParameterMapping> get(Statement catalog_stmt, StmtParameter catalog_stmt_param) {
    assert(catalog_stmt != null);
    assert(catalog_stmt_param != null);
    
    Collection<ParameterMapping> set = new TreeSet<ParameterMapping>();
    StatementMappings mappings = this.stmtIndex.get(catalog_stmt);
    if (mappings != null) {
        for (SortedMap<StmtParameter, SortedSet<ParameterMapping>> m : mappings.values()) {
            if (m.containsKey(catalog_stmt_param)) {
                set.addAll(m.get(catalog_stmt_param));
            }
        } // FOR
    }
    return (set);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:ParameterMappingsSet.java

示例2: getFolders

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * This method returns a list of all folders
 * 
 * @return
 */
private synchronized List<HistoryItem> getFolders() {
	List<HistoryItem> folders = new ArrayList<>();
	SortedMap<String, Integer> folderMap = new TreeMap<>(
			String.CASE_INSENSITIVE_ORDER);
	File bookmarksFile = new File(mContext.getFilesDir(), FILE_BOOKMARKS);
	try {
		BufferedReader bookmarksReader = new BufferedReader(new FileReader(bookmarksFile));
		String line;
		while ((line = bookmarksReader.readLine()) != null) {
			JSONObject object = new JSONObject(line);
			String folderName = object.getString(FOLDER);
			if (!folderName.isEmpty() && !folderMap.containsKey(folderName)) {
				HistoryItem item = new HistoryItem();
				item.setTitle(folderName);
				item.setUrl(Constants.FOLDER + folderName);
				folderMap.put(folderName, 1);
				folders.add(item);
			}
		}
		bookmarksReader.close();
	} catch (IOException | JSONException e) {
		e.printStackTrace();
	}
	return folders;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:31,代码来源:BookmarkManager.java

示例3: putEntryWithChecks

import java.util.SortedMap; //导入方法依赖的package包/类
private static <K, V> void putEntryWithChecks(
    SortedMap<K, V> map, Entry<? extends K, ? extends V> entry) {
  K key = checkNotNull(entry.getKey());
  V value = checkNotNull(entry.getValue());
  if (map.containsKey(key)) {
    // When a collision happens, the colliding entry is the first entry
    // of the tail map.
    Entry<K, V> previousEntry
        = map.tailMap(key).entrySet().iterator().next();
    throw new IllegalArgumentException(
        "Duplicate keys in mappings " + previousEntry.getKey()
        + "=" + previousEntry.getValue() + " and " + key
        + "=" + value);
  }
  map.put(key, value);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:17,代码来源:ImmutableSortedMap.java

示例4: 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

示例5: ImmutableDescriptor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * <p>Construct a descriptor where the names and values of the fields
 * are the keys and values of the given Map.</p>
 *
 * @throws IllegalArgumentException if the parameter is null, or
 * if a field name is null or empty, or if the same field name appears
 * more than once (which can happen because field names are not case
 * sensitive).
 */
public ImmutableDescriptor(Map<String, ?> fields) {
    if (fields == null)
        throw new IllegalArgumentException("Null Map");
    SortedMap<String, Object> map =
            new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (Map.Entry<String, ?> entry : fields.entrySet()) {
        String name = entry.getKey();
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Empty or null field name");
        if (map.containsKey(name))
            throw new IllegalArgumentException("Duplicate name: " + name);
        map.put(name, entry.getValue());
    }
    int size = map.size();
    this.names = map.keySet().toArray(new String[size]);
    this.values = map.values().toArray(new Object[size]);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:ImmutableDescriptor.java

示例6: testFlushedSequenceIdsSentToHMaster

import java.util.SortedMap; //导入方法依赖的package包/类
@Test
public void testFlushedSequenceIdsSentToHMaster()
throws IOException, InterruptedException, ServiceException {
  SortedMap<byte[], Long> allFlushedSequenceIds =
      new TreeMap<byte[], Long>(Bytes.BYTES_COMPARATOR);
  for (int i = 0; i < NUM_RS; ++i) {
    flushAllRegions(i);
  }
  Thread.sleep(10000);
  HMaster master = TEST_UTIL.getMiniHBaseCluster().getMaster();
  for (int i = 0; i < NUM_RS; ++i) {
    for (byte[] regionName : getRegionsByServer(i)) {
      if (allFlushedSequenceIds.containsKey(regionName)) {
        GetLastFlushedSequenceIdRequest req =
          RequestConverter.buildGetLastFlushedSequenceIdRequest(regionName);

        assertEquals((long)allFlushedSequenceIds.get(regionName),
          master.getMasterRpcServices().getLastFlushedSequenceId(
            null, req).getLastFlushedSequenceId());
      }
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestWALFiltering.java

示例7: makeMap

import java.util.SortedMap; //导入方法依赖的package包/类
private static SortedMap<String, Object> makeMap(
        String[] itemNames, Object[] itemValues)
        throws OpenDataException {

    if (itemNames == null || itemValues == null)
        throw new IllegalArgumentException("Null itemNames or itemValues");
    if (itemNames.length == 0 || itemValues.length == 0)
        throw new IllegalArgumentException("Empty itemNames or itemValues");
    if (itemNames.length != itemValues.length) {
        throw new IllegalArgumentException(
                "Different lengths: itemNames[" + itemNames.length +
                "], itemValues[" + itemValues.length + "]");
    }

    SortedMap<String, Object> map = new TreeMap<String, Object>();
    for (int i = 0; i < itemNames.length; i++) {
        String name = itemNames[i];
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Null or empty item name");
        if (map.containsKey(name))
            throw new OpenDataException("Duplicate item name " + name);
        map.put(itemNames[i], itemValues[i]);
    }

    return map;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:CompositeDataSupport.java

示例8: ImmutableDescriptor

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * <p>Construct a descriptor where the names and values of the fields
 * are the keys and values of the given Map.</p>
 *
 * @param fields the field names and values
 * @throws IllegalArgumentException if the parameter is null, or
 * if a field name is null or empty, or if the same field name appears
 * more than once (which can happen because field names are not case
 * sensitive).
 */
public ImmutableDescriptor(Map<String, ?> fields) {
    if (fields == null)
        throw new IllegalArgumentException("Null Map");
    SortedMap<String, Object> map =
            new TreeMap<String, Object>(String.CASE_INSENSITIVE_ORDER);
    for (Map.Entry<String, ?> entry : fields.entrySet()) {
        String name = entry.getKey();
        if (name == null || name.equals(""))
            throw new IllegalArgumentException("Empty or null field name");
        if (map.containsKey(name))
            throw new IllegalArgumentException("Duplicate name: " + name);
        map.put(name, entry.getValue());
    }
    int size = map.size();
    this.names = map.keySet().toArray(new String[size]);
    this.values = map.values().toArray(new Object[size]);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:28,代码来源:ImmutableDescriptor.java

示例9: sortResults

import java.util.SortedMap; //导入方法依赖的package包/类
private SortedMap<Long, List<SampleResult>> sortResults(List<SampleResult> list) {
    SortedMap<Long, List<SampleResult>> sortedResults = new TreeMap<>();

    for (SampleResult result : list) {
        long time = result.getEndTime() / 1000;
        if (!sortedResults.containsKey(time)) {
            sortedResults.put(time, new LinkedList<SampleResult>());
        }
        sortedResults.get(time).add(result);
    }

    return sortedResults;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:14,代码来源:LoadosophiaClient.java

示例10: parse

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Method for parsing orders XML.
 * @param is input stream for parsing.
 * @return SortedMap of OrderBook's mapping key name.
 * @throws FileNotFoundException if there is no such file.
 * @throws XMLStreamException The base exception for unexpected processing errors.  This Exception
 * class is used to report well-formedness errors as well as unexpected
 * processing conditions.
 */
public SortedMap<String, OrderBook> parse(InputStream is) throws FileNotFoundException, XMLStreamException {
    SortedMap<String, OrderBook> orders = new TreeMap<>(String::compareTo);
    XMLInputFactory factory = XMLInputFactory.newInstance();
    XMLStreamReader reader = factory.createXMLStreamReader(is);
    OrderBook orderBook;
    String book;
    reader.next();
    while (reader.hasNext()) {
        if (reader.next() == XMLStreamConstants.START_ELEMENT) {
            if (reader.isStartElement()) {
                book = reader.getAttributeValue(null, "book");
                if ("AddOrder".equals(reader.getLocalName())) {
                    if (!orders.containsKey(book)) {
                        orderBook = new OrderBook(book);
                        orders.put(book, orderBook);
                    } else {
                        orderBook = orders.get(book);
                    }
                    orderBook.addOrder(OrderBook.OPERATION.valueOf(reader.getAttributeValue(null, "operation")),
                            Integer.parseInt(reader.getAttributeValue(null, "orderId")),
                            Integer.parseInt(reader.getAttributeValue(null, "volume")),
                            Float.parseFloat(reader.getAttributeValue(null, "price")));
                } else {
                    orders.get(book).delOrder(Integer.parseInt(reader.getAttributeValue(null, "orderId")));
                }
            }
        }
    }
    return orders;
}
 
开发者ID:PavelZubaha,项目名称:pzubaha,代码行数:40,代码来源:StAXParser.java

示例11: parse

import java.util.SortedMap; //导入方法依赖的package包/类
public SortedMap<String, OrderBook> parse(InputStream is) throws IOException, SAXException {
    SortedMap<String, OrderBook> orders = new TreeMap<>(String::compareTo);
    long start = System.currentTimeMillis();
    Document doc = builder.parse(is);
    System.out.println(System.currentTimeMillis() - start);
    Element element = doc.getDocumentElement();
    NodeList nl = element.getChildNodes();
    NamedNodeMap nnp;
    OrderBook orderBook;
    Node node;
    String bookName;
    //When parse 300 000 elements it takes 11 - 16 sec.
    //Parsing more 320 000 - 360 000 throws OutOfMemoryError.
    for (int i = 0; i < Math.min(200000, nl.getLength()); i++) {
        node = nl.item(i);
        if (!(node instanceof Element)) {
            continue;
        }
        nnp = node.getAttributes();
        bookName = nnp.getNamedItem("book").getNodeValue();
        if (node.getNodeName().contains("AddOrder")) {
            if (!orders.containsKey(bookName)) {
                orderBook = new OrderBook(bookName);
                orders.put(bookName, orderBook);
            } else {
                orderBook = orders.get(bookName);
            }
            orderBook.addOrder((nnp.getNamedItem("operation").getNodeValue().compareTo("BUY") == 0 ? OrderBook.OPERATION.BUY : OrderBook.OPERATION.SELL),
                    Integer.parseInt(nnp.getNamedItem("orderId").getNodeValue()),
                    Integer.parseInt(nnp.getNamedItem("volume").getNodeValue()),
                    Float.valueOf(nnp.getNamedItem("price").getNodeValue()));
        } else {
            orders.get(bookName).delOrder(Integer.parseInt(nnp.getNamedItem("orderId").getNodeValue()));
        }
    }
    return orders;
}
 
开发者ID:PavelZubaha,项目名称:pzubaha,代码行数:38,代码来源:DOMParser.java

示例12: keepDebate

import java.util.SortedMap; //导入方法依赖的package包/类
@Override
public boolean keepDebate(Debate debate)
        throws IOException
{
    // collect counts for each stance
    SortedMap<String, Integer> counts = new TreeMap<>();
    for (Argument argument : debate.getArgumentList()) {
        String stance = argument.getStance();

        if (argument.getParentId() == null) {

            if (!counts.containsKey(stance)) {
                counts.put(stance, 0);
            }
            counts.put(stance, counts.get(stance) + 1);
        }
    }

    // make sure we have two stances
    if (counts.size() < 2) {
        return false;
    }

    // check constraints for each stance
    for (Map.Entry<String, Integer> entry : counts.entrySet()) {
        if (entry.getValue() <= MINIMUM_NUMBER_OF_FIRST_LEVEL_ARGUMENTS_PER_SIDE) {
            return false;
        }
    }

    return true;
}
 
开发者ID:UKPLab,项目名称:argument-reasoning-comprehension-task,代码行数:33,代码来源:MinimumRootArgumentCountFilterCreateDebate.java

示例13: 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

示例14: writeObject

import java.util.SortedMap; //导入方法依赖的package包/类
/**
 * Serializes a {@link DescriptorSupport} to an {@link ObjectOutputStream}.
 */
/* If you set jmx.serial.form to "1.2.0" or "1.2.1", then we are
   bug-compatible with those versions.  Specifically, field names
   are forced to lower-case before being written.  This
   contradicts the spec, which, though it does not mention
   serialization explicitly, does say that the case of field names
   is preserved.  But in 1.2.0 and 1.2.1, this requirement was not
   met.  Instead, field names in the descriptor map were forced to
   lower case.  Those versions expect this to have happened to a
   descriptor they deserialize and e.g. getFieldValue will not
   find a field whose name is spelt with a different case.
*/
private void writeObject(ObjectOutputStream out) throws IOException {
    ObjectOutputStream.PutField fields = out.putFields();
    boolean compat = "1.0".equals(serialForm);
    if (compat)
        fields.put("currClass", currClass);

    /* Purge the field "targetObject" from the DescriptorSupport before
     * serializing since the referenced object is typically not
     * serializable.  We do this here rather than purging the "descriptor"
     * variable below because that HashMap doesn't do case-insensitivity.
     * See CR 6332962.
     */
    SortedMap<String, Object> startMap = descriptorMap;
    if (startMap.containsKey("targetObject")) {
        startMap = new TreeMap<String, Object>(descriptorMap);
        startMap.remove("targetObject");
    }

    final HashMap<String, Object> descriptor;
    if (compat || "1.2.0".equals(serialForm) ||
            "1.2.1".equals(serialForm)) {
        descriptor = new HashMap<String, Object>();
        for (Map.Entry<String, Object> entry : startMap.entrySet())
            descriptor.put(entry.getKey().toLowerCase(), entry.getValue());
    } else
        descriptor = new HashMap<String, Object>(startMap);

    fields.put("descriptor", descriptor);
    out.writeFields();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:45,代码来源:DescriptorSupport.java


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