Java源码示例:gnu.trove.map.TLongIntMap

示例1
@Override
public void invalidated(final Observable observable)
{
	final Map<Long, Color> map                       = new HashMap<>();
	final TLongIntMap      explicitlySpecifiedColors = stream.getExplicitlySpecifiedColorsCopy();
	explicitlySpecifiedColors.forEachEntry((k, v) -> {
		map.put(k, Colors.toColor(new ARGBType(v)));
		return true;
	});
	LOG.debug("internal map={} updated map={}", userSpecifiedColors, map);
	if (!userSpecifiedColors.equals(map))
	{
		userSpecifiedColors.clear();
		userSpecifiedColors.putAll(map);
	}
}
 
示例2
@Override
public JsonElement serialize(
		final HighlightingStreamConverter<?> src,
		final Type typeOfSrc,
		final JsonSerializationContext context)
{
	final JsonObject                     map    = new JsonObject();
	final AbstractHighlightingARGBStream stream = src.getStream();
	map.addProperty(TYPE_KEY, src.getClass().getName());
	map.addProperty(STREAM_TYPE_KEY, stream.getClass().getName());
	map.addProperty(SEED_KEY, stream.getSeed());

	final TLongIntMap specifiedColors = stream.getExplicitlySpecifiedColorsCopy();
	if (specifiedColors.size() > 0)
	{
		final JsonObject colors = new JsonObject();
		final ARGBType   dummy  = new ARGBType();
		for (final TLongIntIterator colorIt = specifiedColors.iterator(); colorIt.hasNext(); )
		{
			colorIt.advance();
			dummy.set(colorIt.value());
			colors.addProperty(Long.toString(colorIt.key()), Colors.toHTML(dummy));
		}
		LOG.debug("Adding specified colors {}", colors);
		map.add(SPECIFIED_COLORS_KEY, colors);

	}

	LOG.debug("Returning serialized converter as {}", map);

	return map;
}
 
示例3
@Test()
public void testMapCreateTest() {
    final long t1 = System.nanoTime();
    final TObjectIntMap<String> map1 = new TObjectIntHashMap<>(5000000, 0.8f, -1);
    final long t2 = System.nanoTime();
    final TLongIntMap map2 = new TLongIntHashMap();
    final long t3 = System.nanoTime();
    System.out.println("Map1:" + ((t2-t1)/1000000d) + " Map2:" + ((t3-t2)/100000d));
}
 
示例4
private static TLongIntMap buildTimestampLookupTable(TLongList timestamps) {
    final TLongIntMap lookupTable = new TLongIntHashMap(timestamps.size(), 4, -1, -1);

    final TLongIterator iter = timestamps.iterator();
    for (int idx = 0; iter.hasNext(); ++idx)
        lookupTable.put(iter.next(), idx);

    return lookupTable;
}
 
示例5
/**
 * Build a lookup table that maps timestamps to their block index.
 *
 * @param partitions The timestamp partition table.
 * @return A lookup table, with the keys being any of the timestamps,
 * mapping to the index in the partitions list.
 */
private static TLongIntMap buildTimestampLookupTable(List<TLongList> partitions) {
    final TLongIntMap lookupTable = new TLongIntHashMap(100, 4, -1, -1);

    final ListIterator<TLongList> iter = partitions.listIterator();
    while (iter.hasNext()) {
        final int partitionIndex = iter.nextIndex();
        iter.next().forEach((ts) -> {
            lookupTable.put(ts, partitionIndex);
            return true;
        });
    }

    return lookupTable;
}
 
示例6
public TLongIntMap getExplicitlySpecifiedColorsCopy()
{
	return new TLongIntHashMap(this.explicitlySpecifiedColors);
}
 
示例7
public BlockMaterialMap(TLongIntMap map) {
    this.map = map;
}