本文整理汇总了Java中com.google.common.collect.Table.put方法的典型用法代码示例。如果您正苦于以下问题:Java Table.put方法的具体用法?Java Table.put怎么用?Java Table.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Table
的用法示例。
在下文中一共展示了Table.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSHRMapping
import com.google.common.collect.Table; //导入方法依赖的package包/类
private static Table<String, String, String> loadSHRMapping() {
if (!USE_SHR_EXTENSIONS) {
// don't bother creating the table unless we need it
return null;
}
Table<String,String,String> mappingTable = HashBasedTable.create();
List<LinkedHashMap<String,String>> csvData;
try {
csvData = SimpleCSV.parse(Utilities.readResource("shr_mapping.csv"));
} catch (IOException e) {
e.printStackTrace();
return null;
}
for (LinkedHashMap<String,String> line : csvData) {
String system = line.get("SYSTEM");
String code = line.get("CODE");
String url = line.get("URL");
mappingTable.put(system, code, url);
}
return mappingTable;
}
示例2: parseMatrix
import com.google.common.collect.Table; //导入方法依赖的package包/类
public static Table<String, String, Float> parseMatrix(Reader reader) throws IOException {
Table<String, String, Float> table = HashBasedTable.create();
try (ICsvListReader csvReader = new CsvListReader(reader, CsvPreference.STANDARD_PREFERENCE)) {
List<String> columnHeaders = csvReader.read();
List<String> row;
while ((row = csvReader.read()) != null) {
String rowHeader = row.get(0);
for (int i = 1; i < row.size(); i++) {
String columnHeader = columnHeaders.get(i);
String value = row.get(i);
table.put(rowHeader, columnHeader, value == null ? Float.NaN : Float.parseFloat(value));
}
}
}
return table;
}
示例3: getConfigItemTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* 将配置项构造成一个二维表,[配置名称, Profile ID, 配置项]
*
* @param configItemList
* @return
*/
private Table<String, Integer, List<BuildConfigItem>> getConfigItemTable(List<BuildConfigItem> configItemList) {
Table<String, Integer, List<BuildConfigItem>> configItemTable = HashBasedTable.create();
List<BuildConfigItem> listByNameAndProfile = null;
for (BuildConfigItem configItem : configItemList) {
listByNameAndProfile = configItemTable.get(configItem.getConfigName(), configItem.getProfileId());
if (listByNameAndProfile == null) {
listByNameAndProfile = new ArrayList<>();
configItemTable.put(configItem.getConfigName(), configItem.getProfileId(), listByNameAndProfile);
}
listByNameAndProfile.add(configItem);
}
return configItemTable;
}
示例4: buildPropertyValueTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
public void buildPropertyValueTable(Map<Map<IProperty, Comparable>, BlockState.StateImplementation> map)
{
if (this.propertyValueTable != null)
{
throw new IllegalStateException();
}
else
{
Table<IProperty, Comparable, IBlockState> table = HashBasedTable.<IProperty, Comparable, IBlockState>create();
for (IProperty <? extends Comparable > iproperty : this.properties.keySet())
{
for (Comparable comparable : iproperty.getAllowedValues())
{
if (comparable != this.properties.get(iproperty))
{
table.put(iproperty, comparable, map.get(this.getPropertiesWithValue(iproperty, comparable)));
}
}
}
this.propertyValueTable = ImmutableTable.<IProperty, Comparable, IBlockState>copyOf(table);
}
}
示例5: rateMatrix
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* retrieve a rating matrix from the tensor. Warning: it assumes there is at most one entry for each (user, item)
* pair.
*
* @return a sparse rating matrix
*/
public SparseMatrix rateMatrix() {
Table<Integer, Integer, Double> dataTable = HashBasedTable.create();
Multimap<Integer, Integer> colMap = HashMultimap.create();
for (TensorEntry te : this) {
int u = te.key(userDimension);
int i = te.key(itemDimension);
dataTable.put(u, i, te.get());
colMap.put(i, u);
}
return new SparseMatrix(dimensions[userDimension], dimensions[itemDimension], dataTable, colMap);
}
示例6: MediaTypeClassifierImpl
import com.google.common.collect.Table; //导入方法依赖的package包/类
MediaTypeClassifierImpl(Iterable<? extends MediaType> mts) {
Table<String, String, Set<MediaType>> typeTable =
HashBasedTable.<String, String, Set<MediaType>>create();
for (MediaType mt : mts) {
String type = mt.type();
String subtype = mt.subtype();
Set<MediaType> typeSet = typeTable.get(type, subtype);
if (typeSet == null) {
typeSet = Sets.newLinkedHashSet();
typeTable.put(type, subtype, typeSet);
}
typeSet.add(mt);
}
ImmutableTable.Builder<String, String, ImmutableSet<MediaType>> b =
ImmutableTable.builder();
for (Table.Cell<String, String, Set<MediaType>> cell
: typeTable.cellSet()) {
b.put(cell.getRowKey(), cell.getColumnKey(), ImmutableSet.copyOf(cell.getValue()));
}
this.types = b.build();
}
示例7: buildPropertyValueTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
public void buildPropertyValueTable(Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map)
{
if (this.propertyValueTable != null)
{
throw new IllegalStateException();
}
else
{
Table < IProperty<?>, Comparable<?>, IBlockState > table = HashBasedTable. < IProperty<?>, Comparable<?>, IBlockState > create();
for (Entry < IProperty<?>, Comparable<? >> entry : this.properties.entrySet())
{
IProperty<?> iproperty = (IProperty)entry.getKey();
for (Comparable<?> comparable : iproperty.getAllowedValues())
{
if (comparable != entry.getValue())
{
table.put(iproperty, comparable, map.get(this.getPropertiesWithValue(iproperty, comparable)));
}
}
}
this.propertyValueTable = ImmutableTable. < IProperty<?>, Comparable<?>, IBlockState > copyOf(table);
}
}
示例8: fillTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
@Override
protected void fillTable(int num, String[] inputs, Table<EspressoTerm, String, EspressoValue> table) {
for(State state : stategraph.getStates()) {
BitSet x = state.getBinaryRepresentationNormalised(stategraph.getAllSignals());
EspressoTerm t = new EspressoTerm(BitSetHelper.formatBitset(x, num), inputs);
for(Signal sig : stategraph.getAllSignals()) {
if(sig.getType() == SignalType.output || sig.getType() == SignalType.internal) {
switch(state.getStateValues().get(sig)) {
case high:
case rising:
table.put(t, sig.getName(), EspressoValue.one);
break;
case falling:
case low:
table.put(t, sig.getName(), EspressoValue.zero);
break;
}
}
}
}
}
示例9: getAllFromRedis
import com.google.common.collect.Table; //导入方法依赖的package包/类
private Table<String, ResourceType, Response<Map<String, String>>> getAllFromRedis(Set<String> userIds) {
if (userIds.size() == 0) {
return HashBasedTable.create();
}
try (Jedis jedis = jedisSource.getJedis()) {
Table<String, ResourceType, Response<Map<String, String>>> responseTable =
ArrayTable.create(userIds, new ArrayIterator<>(ResourceType.values()));
Pipeline p = jedis.pipelined();
for (String userId : userIds) {
for (ResourceType r : ResourceType.values()) {
responseTable.put(userId, r, p.hgetAll(userKey(userId, r)));
}
}
p.sync();
return responseTable;
} catch (Exception e) {
log.error("Storage exception reading all entries.", e);
}
return null;
}
示例10: combineStrandJunctionsMaps
import com.google.common.collect.Table; //导入方法依赖的package包/类
/**
* Combine junctions from both strands. Used for Sashimi plot.
* Note: Flanking depth arrays are not combined.
*/
private List<SpliceJunctionFeature> combineStrandJunctionsMaps() {
// Start with all + junctions
Table<Integer, Integer, SpliceJunctionFeature> combinedStartEndJunctionsMap = HashBasedTable.create(posStartEndJunctionsMap);
// Merge in - junctions
for (Table.Cell<Integer, Integer, SpliceJunctionFeature> negJunctionCell : negStartEndJunctionsMap.cellSet()) {
int junctionStart = negJunctionCell.getRowKey();
int junctionEnd = negJunctionCell.getColumnKey();
SpliceJunctionFeature negFeat = negJunctionCell.getValue();
SpliceJunctionFeature junction = combinedStartEndJunctionsMap.get(junctionStart, junctionEnd);
if (junction == null) {
// No existing (+) junction here, just add the (-) one\
combinedStartEndJunctionsMap.put(junctionStart, junctionEnd, negFeat);
} else {
int newJunctionDepth = junction.getJunctionDepth() + negFeat.getJunctionDepth();
junction.setJunctionDepth(newJunctionDepth);
}
}
return new ArrayList<SpliceJunctionFeature>(combinedStartEndJunctionsMap.values());
}
示例11: main
import com.google.common.collect.Table; //导入方法依赖的package包/类
public static void main(String[] args) {
String[] names = {"Bob", "Alice", "Andy", "Carol", "Ben"};
// Table of names
Table<Character, Integer, String> table = HashBasedTable.create();
// First letter is a row key, length is a column key
for (String name : names) {
table.put(name.charAt(0), name.length(), name);
}
// Value corresponding to the given row and column keys
table.get('A', 5); // -> Alice
table.get('B', 3); // -> Ben
// Set of column keys that have one or more values in the table
table.columnKeySet(); // -> [4, 5, 3]
// View of all mappings that have the given row key
table.row('A'); // -> {4=Andy, 5=Alice}
}
示例12: loadTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
public static Table<String, String, Long> loadTable(InputStream stream)
throws IOException
{
Table<String, String, Long> result = TreeBasedTable.create();
LineIterator lineIterator = IOUtils.lineIterator(stream, "utf-8");
while (lineIterator.hasNext()) {
String line = lineIterator.next();
System.out.println(line);
String[] split = line.split("\t");
String language = split[0];
String license = split[1];
Long documents = Long.valueOf(split[2]);
Long tokens = Long.valueOf(split[3]);
result.put(language, "docs " + license, documents);
result.put(language, "tokens " + license, tokens);
}
return result;
}
示例13: getSMTProgramUpdateInfos
import com.google.common.collect.Table; //导入方法依赖的package包/类
private Table<SMTProgram, Stmt, List<Pair<DynamicValueInformation, DynamicValue>>> getSMTProgramUpdateInfos(DynamicValueContainer dynamicValues) {
Table<SMTProgram, Stmt, List<Pair<DynamicValueInformation, DynamicValue>>> updateInfoTable = HashBasedTable.create();
for(DynamicValue value : dynamicValues.getValues()) {
Unit unit = codePositionManager.getUnitForCodePosition(value.getCodePosition()+1);
int paramIdx = value.getParamIdx();
for(Map.Entry<SMTProgram, Set<DynamicValueInformation>> entry : dynamicValueInfos.entrySet()) {
for(DynamicValueInformation valueInfo : entry.getValue()) {
if(valueInfo.getStatement().equals(unit)) {
//base object
if(paramIdx == -1) {
if(valueInfo.isBaseObject()) {
if(!updateInfoTable.contains(entry.getKey(), valueInfo.getStatement()))
updateInfoTable.put(entry.getKey(), valueInfo.getStatement(), new ArrayList<Pair<DynamicValueInformation, DynamicValue>>());
updateInfoTable.get(entry.getKey(), valueInfo.getStatement()).add(new Pair<DynamicValueInformation, DynamicValue>(valueInfo, value));
}
}
//method arguments
else{
if(valueInfo.getArgPos() == paramIdx) {
if(!updateInfoTable.contains(entry.getKey(), valueInfo.getStatement()))
updateInfoTable.put(entry.getKey(), valueInfo.getStatement(), new ArrayList<Pair<DynamicValueInformation, DynamicValue>>());
updateInfoTable.get(entry.getKey(), valueInfo.getStatement()).add(new Pair<DynamicValueInformation, DynamicValue>(valueInfo, value));
}
}
}
}
}
}
return updateInfoTable;
}
示例14: headerTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
public Builder headerTable(Map<String, String> headerMap) {
Table<String, String, String> table = HashBasedTable.create();
for (Entry<String, String> en : headerMap.entrySet()) {
String[] parts = en.getKey().split("\\.", 2);
table.put(parts[0], parts[1], en.getValue());
}
this.headerTable = table;
return this;
}
示例15: getTable
import com.google.common.collect.Table; //导入方法依赖的package包/类
private Table<String, String, String> getTable(Context context, String prefix) {
Table<String, String, String> table = HashBasedTable.create();
for (Entry<String, String> e : context.getSubProperties(prefix).entrySet()) {
String[] parts = e.getKey().split("\\.", 2);
table.put(parts[0], parts[1], e.getValue());
}
return table;
}