本文整理匯總了Java中com.google.common.collect.ImmutableSortedMap.naturalOrder方法的典型用法代碼示例。如果您正苦於以下問題:Java ImmutableSortedMap.naturalOrder方法的具體用法?Java ImmutableSortedMap.naturalOrder怎麽用?Java ImmutableSortedMap.naturalOrder使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.ImmutableSortedMap
的用法示例。
在下文中一共展示了ImmutableSortedMap.naturalOrder方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectManagedProperties
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
private <T> ImmutableSortedMap<String, ManagedProperty<?>> collectManagedProperties(StructBindingExtractionContext<T> extractionContext, Map<String, Multimap<PropertyAccessorType, StructMethodBinding>> propertyBindings) {
ImmutableSortedMap.Builder<String, ManagedProperty<?>> managedPropertiesBuilder = ImmutableSortedMap.naturalOrder();
for (Map.Entry<String, Multimap<PropertyAccessorType, StructMethodBinding>> propertyEntry : propertyBindings.entrySet()) {
String propertyName = propertyEntry.getKey();
Multimap<PropertyAccessorType, StructMethodBinding> accessorBindings = propertyEntry.getValue();
if (isManagedProperty(extractionContext, propertyName, accessorBindings)) {
if (hasSetter(accessorBindings.keySet()) && !hasGetter(accessorBindings.keySet())) {
extractionContext.add(propertyName, "it must both have an abstract getter and a setter");
continue;
}
ModelType<?> propertyType = determineManagedPropertyType(extractionContext, propertyName, accessorBindings);
ModelSchema<?> propertySchema = schemaStore.getSchema(propertyType);
managedPropertiesBuilder.put(propertyName, createManagedProperty(extractionContext, propertyName, propertySchema, accessorBindings));
}
}
return managedPropertiesBuilder.build();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例12: 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);
}
示例13: ColumnRegistrar
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
public ColumnRegistrar(TableIdent tableIdent, RowGranularity rowGranularity) {
this.tableIdent = tableIdent;
this.rowGranularity = rowGranularity;
this.infosBuilder = ImmutableSortedMap.naturalOrder();
this.columnsBuilder = ImmutableSortedSet.orderedBy(ReferenceInfo.COMPARE_BY_COLUMN_IDENT);
}
示例14: create
import com.google.common.collect.ImmutableSortedMap; //導入方法依賴的package包/類
public static ImmutableSortedMap.Builder<String, String> create()
{
return ImmutableSortedMap.<String, String>naturalOrder();
}