當前位置: 首頁>>代碼示例>>Java>>正文


Java ImmutableSortedMap.Builder方法代碼示例

本文整理匯總了Java中com.google.common.collect.ImmutableSortedMap.Builder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableSortedMap.Builder方法的具體用法?Java ImmutableSortedMap.Builder怎麽用?Java ImmutableSortedMap.Builder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.ImmutableSortedMap的用法示例。


在下文中一共展示了ImmutableSortedMap.Builder方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: AbstractStructSchema

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
public AbstractStructSchema(
    ModelType<T> type,
    Iterable<ModelProperty<?>> properties,
    Iterable<WeaklyTypeReferencingMethod<?, ?>> nonPropertyMethods,
    Iterable<ModelSchemaAspect> aspects
) {
    super(type);
    ImmutableSortedMap.Builder<String, ModelProperty<?>> builder = ImmutableSortedMap.naturalOrder();
    for (ModelProperty<?> property : properties) {
        builder.put(property.getName(), property);
    }
    this.properties = builder.build();
    this.nonPropertyMethods = ImmutableSet.copyOf(nonPropertyMethods);
    this.aspects = Maps.uniqueIndex(aspects, new Function<ModelSchemaAspect, Class<? extends ModelSchemaAspect>>() {
        @Override
        public Class<? extends ModelSchemaAspect> apply(ModelSchemaAspect aspect) {
            return aspect.getClass();
        }
    });
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:21,代碼來源:AbstractStructSchema.java

示例2: drawDistanceDiscounts

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
/**
 * Determines the discount in value for distant regions
 */
public ImmutableSortedMap<Integer, BigDecimal> drawDistanceDiscounts(MRVMWorld world, MRVMRegionsMap.Region home, UniformDistributionRNG rng) {
    ImmutableSortedMap.Builder<Integer, BigDecimal> distanceDiscount = ImmutableSortedMap.naturalOrder();
    distanceDiscount.put(0, BigDecimal.ONE);
    int maxDistance = world.getRegionsMap().getLongestShortestPath(home);
    for (int i = 1; i <= maxDistance; i++) {
        double exponent = exponentFactor * i * (-1);
        double gamma = Math.pow(base, exponent);

        Preconditions.checkState(gamma >= 0 && gamma <= 1, "Invalid Gamma, some of the calculation parameters have unallowed values");

        BigDecimal roundedGamma = BigDecimal.valueOf(gamma).setScale(5, BigDecimal.ROUND_HALF_DOWN);
        distanceDiscount.put(i, roundedGamma);
    }
    return distanceDiscount.build();
}
 
開發者ID:spectrumauctions,項目名稱:sats-core,代碼行數:19,代碼來源:MRVMRegionalBidderSetup.java

示例3: buildGammaMap

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
private static ImmutableSortedMap<Integer, BigDecimal> buildGammaMap(Map<Integer, BigDecimal> gammaInput) {
    ImmutableSortedMap.Builder<Integer, BigDecimal> mapBuilder = ImmutableSortedMap.naturalOrder();
    SortedMap<Integer, BigDecimal> sortedInput = new TreeMap<>(gammaInput);
    Preconditions.checkArgument(sortedInput.firstKey() == 1,
            "Gamma Values must (exclusively) be specified for quantities 1 and (optionally) higher",
            sortedInput);
    Preconditions.checkArgument(sortedInput.lastKey().equals(sortedInput.size()), ""
                    + "Gamma Values must be specified for all capacities in {0, ..., k_{max}}, where k_{max} > 0 is any natural number > 0",
            sortedInput);

    for (Entry<Integer, BigDecimal> inputGammaEntry : sortedInput.entrySet()) {
        Preconditions.checkArgument(inputGammaEntry.getValue().compareTo(BigDecimal.ZERO) >= 0, "Gamma must not be negative", inputGammaEntry);
        mapBuilder.put(inputGammaEntry);
    }
    return mapBuilder.build();
}
 
開發者ID:spectrumauctions,項目名稱:sats-core,代碼行數:17,代碼來源:MRVMNationalBidder.java

示例4: ContinuousPiecewiseLinearFunction

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
/**
 * Constructs a new PieceWiseLinear function with a restricted domain interval
 * @param cornerPoints A map with <i>key = x-values</i> and <i> value = y-values</i>. 
 * The map has to include all corner points of the function, including lower and upper end of domain. <br>
 *
 */
public ContinuousPiecewiseLinearFunction(Map<BigDecimal, BigDecimal> cornerPoints) {
    // Sort the incoming corner points by their 
    SortedMap<BigDecimal, BigDecimal> sortedCornerPoints = new TreeMap<>(cornerPoints);
    ImmutableSortedMap.Builder<BigDecimal, LinearFunction> linearFunctionsBuilder =
            ImmutableSortedMap.naturalOrder();
    Iterator<Entry<BigDecimal, BigDecimal>> entryIterator = sortedCornerPoints.entrySet().iterator();
    Entry<BigDecimal, BigDecimal> lowerEntry = entryIterator.next();
    lowestX = lowerEntry.getKey();
    while (entryIterator.hasNext()) {
        Entry<BigDecimal, BigDecimal> upperEntry = entryIterator.next();
        if (lowerEntry.getKey().compareTo(upperEntry.getKey()) == 0) {
            // Skip linear function where the domain is empty
            // TODO log this
        } else {
            LinearFunction linearFunction = new LinearFunction(lowerEntry.getKey(), lowerEntry.getValue(), upperEntry.getKey(), upperEntry.getValue());
            linearFunctionsBuilder.put(upperEntry.getKey(), linearFunction);
            lowerEntry = upperEntry;
        }
    }
    linearFunctions = linearFunctionsBuilder.build();
}
 
開發者ID:spectrumauctions,項目名稱:sats-core,代碼行數:28,代碼來源:ContinuousPiecewiseLinearFunction.java

示例5: SaveAsDataPointAggregator

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
public SaveAsDataPointAggregator(DataPointGroup innerDataPointGroup)
{
	m_innerDataPointGroup = innerDataPointGroup;
	ImmutableSortedMap.Builder<String, String> mapBuilder = ImmutableSortedMap.<String, String>naturalOrder();
	mapBuilder.putAll(m_tags);
	if (m_addSavedFrom)
		mapBuilder.put("saved_from", innerDataPointGroup.getName());

	for (String innerTag : innerDataPointGroup.getTagNames())
	{
		Set<String> tagValues = innerDataPointGroup.getTagValues(innerTag);
		if (m_tagsToKeep.contains(innerTag) && (tagValues.size() == 1))
			mapBuilder.put(innerTag, tagValues.iterator().next());
	}

	m_groupTags = mapBuilder.build();
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:18,代碼來源:SaveAsAggregator.java

示例6: create

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Override
protected List<String> create(String[] elements) {
  ImmutableSortedMap.Builder<String, Integer> builder = ImmutableSortedMap.naturalOrder();
  for (int i = 0; i < elements.length; i++) {
    builder.put(elements[i], i);
  }
  return builder.build().keySet().asList();
}
 
開發者ID:paul-hammant,項目名稱:googles-monorepo-demo,代碼行數:9,代碼來源:SortedMapGenerators.java

示例7: getInputFilesSnapshot

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Override
public Map<String, FileCollectionSnapshot> getInputFilesSnapshot() {
    if (inputFilesSnapshot == null) {
        ImmutableSortedMap.Builder<String, FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
        for (Map.Entry<String, Long> entry : inputFilesSnapshotIds.entrySet()) {
            builder.put(entry.getKey(), snapshotRepository.get(entry.getValue()));
        }
        inputFilesSnapshot = builder.build();
    }
    return inputFilesSnapshot;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:12,代碼來源:CacheBackedTaskHistoryRepository.java

示例8: getOutputFilesSnapshot

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Override
public Map<String, FileCollectionSnapshot> getOutputFilesSnapshot() {
    if (outputFilesSnapshot == null) {
        ImmutableSortedMap.Builder<String, FileCollectionSnapshot> builder = ImmutableSortedMap.naturalOrder();
        for (Map.Entry<String, Long> entry : outputFilesSnapshotIds.entrySet()) {
            String propertyName = entry.getKey();
            builder.put(propertyName, snapshotRepository.get(entry.getValue()));
        }
        outputFilesSnapshot = builder.build();
    }
    return outputFilesSnapshot;
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:13,代碼來源:CacheBackedTaskHistoryRepository.java

示例9: readSnapshotIds

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
private static ImmutableSortedMap<String, Long> readSnapshotIds(Decoder decoder) throws IOException {
    int count = decoder.readSmallInt();
    ImmutableSortedMap.Builder<String, Long> builder = ImmutableSortedMap.naturalOrder();
    for (int snapshotIdx = 0; snapshotIdx < count; snapshotIdx++) {
        String property = decoder.readString();
        long id = decoder.readLong();
        builder.put(property, id);
    }
    return builder.build();
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:11,代碼來源:CacheBackedTaskHistoryRepository.java

示例10: AbstractReflectionThriftCodec

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
protected AbstractReflectionThriftCodec(ThriftCodecManager manager, ThriftStructMetadata metadata)
{
    this.metadata = metadata;

    ImmutableSortedMap.Builder<Short, ThriftCodec<?>> fields = ImmutableSortedMap.naturalOrder();
    for (ThriftFieldMetadata fieldMetadata : metadata.getFields(THRIFT_FIELD)) {
        fields.put(fieldMetadata.getId(), manager.getCodec(fieldMetadata.getThriftType()));
    }
    this.fields = fields.build();
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:11,代碼來源:AbstractReflectionThriftCodec.java

示例11: create

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
@Override
public SortedMap<String, String> create(Entry<String, String>[] entries) {
  ImmutableSortedMap.Builder<String, String> builder = ImmutableSortedMap.naturalOrder();
  for (Entry<String, String> entry : entries) {
    checkNotNull(entry);
    builder.put(entry.getKey(), entry.getValue());
  }
  return builder.build();
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:10,代碼來源:SortedMapGenerators.java

示例12: ImmutableWeightedRandomChooser

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
/**
 * Construct a chooser with the given items
 * @param weights Map of items to weights
 */
public ImmutableWeightedRandomChooser(Map<T, N> weights) {
    final ImmutableSortedMap.Builder<Double, Option> builder = ImmutableSortedMap.naturalOrder();
    double total = 0;
    for(Map.Entry<T, N> entry : weights.entrySet()) {
        double weight = entry.getValue().doubleValue();
        if(weight > 0) {
            total += weight;
            builder.put(total, new Option(entry.getKey(), weight));
        }
    }
    this.options = builder.build();
    this.totalWeight = total;
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:18,代碼來源:ImmutableWeightedRandomChooser.java

示例13: collate

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
static <T extends Comparable<T>, V>
Trie<T, V> collate(List<Map.Entry<List<T>, V>> entries, int depth, int left, int right) {
  V value = null;
  ImmutableSortedMap.Builder<T, Trie<T, V>> b = ImmutableSortedMap.naturalOrder();

  int childLeft = left;
  Map.Entry<List<T>, V> leftEntry = null;
  if (left != right) {
    leftEntry = entries.get(childLeft);
    if (leftEntry.getKey().size() == depth) {
      value = leftEntry.getValue();
      ++childLeft;
      leftEntry = childLeft < right
          ? Preconditions.checkNotNull(entries.get(childLeft)) : null;
    }
  }

  if (childLeft < right) {
    T keyAtDepth = Preconditions.checkNotNull(leftEntry).getKey().get(depth);
    for (int i = childLeft + 1; i < right; ++i) {
      Map.Entry<List<T>, V> e = entries.get(i);
      T k = e.getKey().get(depth);
      if (keyAtDepth.compareTo(k) != 0) {
        b.put(keyAtDepth, collate(entries, depth + 1, childLeft, i));
        childLeft = i;
        keyAtDepth = k;
      }
    }
    if (childLeft < right) {
      b.put(keyAtDepth, collate(entries, depth + 1, childLeft, right));
    }
  }

  return new Trie<T, V>(b.build(), value);
}
 
開發者ID:OWASP,項目名稱:url-classifier,代碼行數:36,代碼來源:Trie.java

示例14: create

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
public static ImmutableSortedMap.Builder<String, String> create()
{
	return ImmutableSortedMap.<String, String>naturalOrder();
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:5,代碼來源:Tags.java

示例15: execute

import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
protected void execute(String[] command, long timestamp) throws ValidationException, DatastoreException
{
	Validator.validateNotNullOrEmpty("metricName", command[1]);

	String metricName = command[1];
	int ttl = 0;

	DataPoint dp;
	try
	{
		if (command[3].contains("."))
			dp = m_doubleFactory.createDataPoint(timestamp, Double.parseDouble(command[3]));
		else
			dp = m_longFactory.createDataPoint(timestamp, Util.parseLong(command[3]));
	}
	catch (NumberFormatException e)
	{
		throw new ValidationException(e.getMessage());
	}

	ImmutableSortedMap.Builder<String, String> tags = Tags.create();

	int tagCount = 0;
	for (int i = 4; i < command.length; i++)
	{
		String[] tag = command[i].split("=");
		validateTag(tagCount, tag);

		if ("kairos_opt.ttl".equals(tag[0]))
		{
			try
			{
				ttl = Integer.parseInt(tag[1]);
			}
			catch (NumberFormatException nfe)
			{
				throw new ValidationException("tag[kairos_opt.ttl] must be a number");
			}

		}
		else
		{
			tags.put(tag[0], tag[1]);
			tagCount++;
		}
	}

	if (tagCount == 0)
		tags.put("add", "tag");

	m_counter.incrementAndGet();
	m_datastore.putDataPoint(metricName, tags.build(), dp, ttl);
}
 
開發者ID:quqiangsheng,項目名稱:abhot,代碼行數:54,代碼來源:PutMillisecondCommand.java


注:本文中的com.google.common.collect.ImmutableSortedMap.Builder方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。