com.google.common.collect.ImmutableSortedMap#copyOf ( )源码实例Demo

下面列出了com.google.common.collect.ImmutableSortedMap#copyOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: immutables   文件: LongBits.java
LongPositions(Iterable<? extends Object> elements, final int bitPerLong) {
  this.elements = ImmutableList.copyOf(elements);
  checkArgument(bitPerLong <= BITS_IN_LONG, bitPerLong);

  for (int i = 0; i < this.elements.size(); i++) {
    positions.put(
        this.elements.get(i),
        new BitPosition(
            i / bitPerLong,
            i % bitPerLong));
  }

  this.longPositions = ImmutableSortedMap.copyOf(
      Maps.transformEntries(
          Multimaps.index(positions.values(), ToLongIndex.FUNCTION).asMap(),
          new Maps.EntryTransformer<Integer, Collection<BitPosition>, LongSet>() {
            @Override
            public LongSet transformEntry(Integer key, Collection<BitPosition> position) {
              return new LongSet(key, position);
            }
          }));
}
 
源代码2 项目: buck   文件: CxxFlags.java
/** Expand flag macros in all CxxPlatform StringArg flags. */
public static void translateCxxPlatformFlags(
    CxxPlatform.Builder cxxPlatformBuilder,
    CxxPlatform cxxPlatform,
    ImmutableMap<String, Arg> flagMacros) {
  Function<Arg, Arg> translateFunction =
      new CxxFlags.TranslateMacrosArgsFunction(ImmutableSortedMap.copyOf(flagMacros));
  Function<ImmutableList<Arg>, ImmutableList<Arg>> expandMacros =
      flags -> flags.stream().map(translateFunction).collect(ImmutableList.toImmutableList());
  cxxPlatformBuilder.setAsflags(expandMacros.apply(cxxPlatform.getAsflags()));
  cxxPlatformBuilder.setAsppflags(expandMacros.apply(cxxPlatform.getAsppflags()));
  cxxPlatformBuilder.setCflags(expandMacros.apply(cxxPlatform.getCflags()));
  cxxPlatformBuilder.setCxxflags(expandMacros.apply(cxxPlatform.getCxxflags()));
  cxxPlatformBuilder.setCppflags(expandMacros.apply(cxxPlatform.getCppflags()));
  cxxPlatformBuilder.setCxxppflags(expandMacros.apply(cxxPlatform.getCxxppflags()));
  cxxPlatformBuilder.setCudappflags(expandMacros.apply(cxxPlatform.getCudappflags()));
  cxxPlatformBuilder.setCudaflags(expandMacros.apply(cxxPlatform.getCudaflags()));
  cxxPlatformBuilder.setHipppflags(expandMacros.apply(cxxPlatform.getHipppflags()));
  cxxPlatformBuilder.setHipflags(expandMacros.apply(cxxPlatform.getHipflags()));
  cxxPlatformBuilder.setAsmppflags(expandMacros.apply(cxxPlatform.getAsmppflags()));
  cxxPlatformBuilder.setAsmflags(expandMacros.apply(cxxPlatform.getAsmflags()));
  cxxPlatformBuilder.setLdflags(expandMacros.apply(cxxPlatform.getLdflags()));
  cxxPlatformBuilder.setStripFlags(expandMacros.apply(cxxPlatform.getStripFlags()));
  cxxPlatformBuilder.setArflags(expandMacros.apply(cxxPlatform.getArflags()));
  cxxPlatformBuilder.setRanlibflags(expandMacros.apply(cxxPlatform.getRanlibflags()));
}
 
源代码3 项目: bazel   文件: TreeArtifactValue.java
/**
 * Returns a TreeArtifactValue out of the given Artifact-relative path fragments and their
 * corresponding FileArtifactValues.
 */
static TreeArtifactValue create(
    Map<TreeFileArtifact, ? extends FileArtifactValue> childFileValues) {
  if (childFileValues.isEmpty()) {
    return EMPTY;
  }
  Map<String, FileArtifactValue> digestBuilder =
      Maps.newHashMapWithExpectedSize(childFileValues.size());
  boolean entirelyRemote = true;
  for (Map.Entry<TreeFileArtifact, ? extends FileArtifactValue> e : childFileValues.entrySet()) {
    TreeFileArtifact child = e.getKey();
    FileArtifactValue value = e.getValue();
    Preconditions.checkState(
        !FileArtifactValue.OMITTED_FILE_MARKER.equals(value),
        "Cannot construct TreeArtifactValue because child %s was omitted",
        child);
    // Tolerate a tree artifact having a mix of local and remote children (b/152496153#comment80).
    entirelyRemote &= value.isRemote();
    digestBuilder.put(child.getParentRelativePath().getPathString(), value);
  }
  return new TreeArtifactValue(
      DigestUtils.fromMetadata(digestBuilder),
      ImmutableSortedMap.copyOf(childFileValues),
      entirelyRemote);
}
 
源代码4 项目: sequence-mining   文件: FrequentSequenceMining.java
/** Convert frequent sequences to sorted Map<Sequence, Integer> */
public static SortedMap<Sequence, Integer> toMap(final SequentialPatterns patterns) {
	if (patterns == null) {
		return null;
	} else {
		final HashMap<Sequence, Integer> sequences = new HashMap<>();
		for (final List<SequentialPattern> level : patterns.levels) {
			for (final SequentialPattern pattern : level) {
				final Sequence seq = new Sequence();
				for (final Itemset set : pattern.getItemsets())
					seq.add(set.get(0)); // Assumes a seq is just singleton
											// itemsets
				sequences.put(seq, pattern.getAbsoluteSupport());
			}
		}
		// Sort patterns by support
		final Ordering<Sequence> comparator = Ordering.natural().reverse().onResultOf(Functions.forMap(sequences))
				.compound(Ordering.usingToString());
		return ImmutableSortedMap.copyOf(sequences, comparator);
	}
}
 
源代码5 项目: onos   文件: LionBundle.java
private Map<String, String> createLookup() {
    Map<String, String> lookup = new HashMap<>(items.size());
    for (LionItem item : items) {
        lookup.put(item.key(), item.value());
    }
    return ImmutableSortedMap.copyOf(lookup);
}
 
源代码6 项目: sequence-mining   文件: SequenceMiningCore.java
/** Sort sequences by interestingness */
public static Map<Sequence, Double> sortSequences(final HashMap<Sequence, Double> sequences,
		final HashMap<Sequence, Double> intMap) {

	final Ordering<Sequence> comparator = Ordering.natural().reverse().onResultOf(Functions.forMap(intMap))
			.compound(Ordering.natural().reverse().onResultOf(Functions.forMap(sequences)))
			.compound(Ordering.usingToString());
	final Map<Sequence, Double> sortedSequences = ImmutableSortedMap.copyOf(sequences, comparator);

	return sortedSequences;
}
 
源代码7 项目: batfish   文件: Configuration.java
@JsonProperty(PROP_IPSEC_PEER_CONFIGS)
public void setIpsecPeerConfigs(
    @Nullable NavigableMap<String, IpsecPeerConfig> ipsecPeerConfigs) {
  _ipsecPeerConfigs =
      ipsecPeerConfigs == null
          ? ImmutableSortedMap.of()
          : ImmutableSortedMap.copyOf(ipsecPeerConfigs);
}
 
源代码8 项目: tez   文件: VertexLevelCriticalPathAnalyzer.java
private static Map<String, Long> sortByValues(Map<String, Long> result) {
  //Sort result by time in reverse order
  final Ordering<String> reversValueOrdering =
      Ordering.natural().reverse().nullsLast().onResultOf(Functions.forMap(result, null));
  Map<String, Long> orderedMap = ImmutableSortedMap.copyOf(result, reversValueOrdering);
  return orderedMap;
}
 
源代码9 项目: james-project   文件: EventFactory.java
AddedFinalStage(Event.EventId eventId, MailboxPath path, MailboxId mailboxId, Username username, MailboxSession.SessionId sessionId, Map<MessageUid, MessageMetaData> metaData) {
    this.eventId = eventId;
    this.path = path;
    this.mailboxId = mailboxId;
    this.username = username;
    this.sessionId = sessionId;
    this.metaData = ImmutableSortedMap.copyOf(metaData);
}
 
源代码10 项目: api-mining   文件: CollectionUtil.java
/** Sort map by value (highest first) */
public static <K extends Comparable<K>, V extends Comparable<V>> Map<K, V> sortMapByValueDescending(
		final Map<K, V> map) {
	final Ordering<K> valueThenKeyComparator = Ordering.natural().reverse()
			.onResultOf(Functions.forMap(map))
			.compound(Ordering.<K> natural().reverse());
	return ImmutableSortedMap.copyOf(map, valueThenKeyComparator);
}
 
源代码11 项目: batfish   文件: Vrf.java
public void setAppliedRibGroups(Map<RoutingProtocol, RibGroup> appliedRibGroups) {
  _appliedRibGroups = ImmutableSortedMap.copyOf(appliedRibGroups);
}
 
源代码12 项目: bazel   文件: ConfigFeatureFlagTransitionFactory.java
public ConfigFeatureFlagValuesTransition(Map<Label, String> flagValues) {
  this(ImmutableSortedMap.copyOf(flagValues), flagValues.hashCode());
}
 
源代码13 项目: presto   文件: FeatureVector.java
public FeatureVector(Map<Integer, Double> features)
{
    this.features = ImmutableSortedMap.copyOf(features);
}
 
源代码14 项目: jpmml-evaluator   文件: SparseArrayUtil.java
@Override
public SortedMap<Integer, ? extends Number> load(SparseArray<?> sparseArray){
	return ImmutableSortedMap.copyOf(parse(sparseArray));
}
 
源代码15 项目: batfish   文件: Configuration.java
@JsonProperty(PROP_COMMUNITY_SET_EXPRS)
private @Nonnull NavigableMap<String, CommunitySetExpr> getCommunitySetExprsSorted() {
  return ImmutableSortedMap.copyOf(_communitySetExprs);
}
 
源代码16 项目: Quicksql   文件: NameMap.java
/** Creates a NameMap that is an immutable copy of a given map. */
public static <V> NameMap immutableCopyOf(Map<String, V> names) {
  return new NameMap<>(ImmutableSortedMap.copyOf(names, COMPARATOR));
}
 
源代码17 项目: snowblossom   文件: FieldScan.java
public void scan(boolean report)
{
  TreeMap<Integer, SnowMerkleProof> fmap = new TreeMap<>();

  for(Map.Entry<Integer, String> me : params.getFieldSeeds().entrySet())
  {
    int field_number = me.getKey();
    SnowFieldInfo info = params.getSnowFieldInfo(field_number);
    String name = me.getValue();
    File field_folder = new File(path, name);
    if (field_folder.exists() && field_folder.isDirectory())
    {
      try
      {
        double precacheGig = config.getDoubleWithDefault("memfield_precache_gb", 0);
        int minDepthToDisk = config.getIntWithDefault("min_depth_to_disk", 0);
        boolean memfield = config.getBoolean("memfield");
        long precache = 0;
        if (precacheGig > 0.01)
        {
          memfield = false;
          precache = (long)(precacheGig * 1024.0 * 1024.0 * 1024.0);
        }
        logger.info("creating field: " + field_folder + " memfield=" + memfield + ", precache=" + precache + ", minDepthToDisk=" + minDepthToDisk);
        SnowMerkleProof proof = new SnowMerkleProof(field_folder, name, memfield, precache, minDepthToDisk);

        for(int i = 0; i<64; i++)
        {
          checkField(field_number, proof);
        }

        fmap.put(field_number, proof);
        logger.info(String.format("Snow field %d %s (%s) is working", field_number,
          name,
          info.getName()));

      }
      catch(Throwable e)
      {
        logger.info(String.format("Unable to load %s, error: %s", name, e.toString()));
      }
    }
    else
    {
      logger.info(String.format("Not loading %d %s (%s), directory not present: %s",
        field_number,
        name,
        info.getName(),
        field_folder));
    }
  }

  availible_fields = ImmutableSortedMap.copyOf(fmap);

}
 
源代码18 项目: jimfs   文件: FileTree.java
/** Creates a new file tree with the given root directories. */
FileTree(Map<Name, Directory> roots) {
  this.roots = ImmutableSortedMap.copyOf(roots, Name.canonicalOrdering());
}
 
源代码19 项目: batfish   文件: Configuration.java
@JsonProperty(PROP_IKE_PHASE1_KEYS)
public void setIkePhase1Keys(@Nullable NavigableMap<String, IkePhase1Key> ikePhase1Keys) {
  _ikePhase1keys =
      ikePhase1Keys == null ? ImmutableSortedMap.of() : ImmutableSortedMap.copyOf(ikePhase1Keys);
}
 
源代码20 项目: Strata   文件: MultiCurrencyAmountArray.java
@ImmutableConstructor
private MultiCurrencyAmountArray(int size, Map<Currency, DoubleArray> values) {
  this.values = ImmutableSortedMap.copyOf(values);
  this.size = size;
}