Java 类com.google.common.collect.HashBasedTable 实例源码

项目:cheetah    文件:LayeredAnalysis.java   
private void initIFDS() {
    Scene.v().setCallGraph(new CallGraph());
    this.jumpFunctions = new JumpFunctions<Unit, FlowAbstraction, IFDSSolver.BinaryDomain>(IFDSSolver.getAllTop());
    this.endSum = HashBasedTable.create();
    this.inc = HashBasedTable.create();
    this.icfg = new JitIcfg(new ArrayList<SootMethod>()) {
        @Override
        public Set<SootMethod> getCalleesOfCallAt(Unit u) {
            if (currentTask != null)
                return currentTask.calleesOfCallAt(u);
            else // Empty by default (same behaviour as L1)
                return new HashSet<SootMethod>();
        }
    };
    this.reporter.setIFDS(icfg, jumpFunctions);
}
项目:synthea_java    文件:FhirStu3.java   
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;
}
项目:powsybl-core    文件:MathUtil.java   
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;
}
项目:configx    文件:ConfigRestService.java   
/**
 * 将配置项构造成一个二维表,[配置名称, 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;
}
项目:hue    文件:PlanGenerator.java   
private List<OptimizedPlan> getPlansForDimensions() {
    cm.sortForDimensions();
    HashBasedTable<Table, Expressible, PlanPath> matrix = cm.getMatrix();
    ArrayList<Table> sk = cm.getSortedKeys();
    logger.debug(cm.toString());

    List<Expressible> dims = matrix.columnKeySet().stream().filter((vn) -> {
        return (vn instanceof Dimension);
    }).collect(Collectors.toList());

    OptimizedPlan op = new OptimizedPlan();
    int count = 0;
    double cost = 0;
    for(Entry<Expressible, PlanPath> v : matrix.row(sk.get(0)).entrySet()){
        dims.remove(v.getKey());
        op.addPath(v.getValue());
        cost += v.getValue().getCost();
        count++;
    }
    op.setPlanCost(cost/count);

    op.addDisjointedPlans(getDisjoinPlans(dims,op));

    return Lists.newArrayList(op);
}
项目:DecompiledMinecraft    文件:BlockState.java   
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);
    }
}
项目:DecompiledMinecraft    文件:BlockState.java   
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);
    }
}
项目:BaseClient    文件:BlockState.java   
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);
    }
}
项目:BaseClient    文件:BlockState.java   
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);
    }
}
项目:MicroServiceProject    文件:SparseTensor.java   
/**
 * 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);
}
项目:url-classifier    文件:MediaTypeClassifierBuilder.java   
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();
}
项目:cakes    文件:HashBasedTableDemo.java   
@Test
public void testCreate() {
    HashBasedTable<String, String, String> table = HashBasedTable.create();

    table.put("cbooy", "vm", "10.94.97.94");
    table.put("cbooy", "name", "haoc");
    table.put("hello", "name", "hi");
    table.put("hello", "vm", "10999");

    System.out.println(table);

    // 遍历
    table.cellSet().forEach(cell -> {
        String columnKey = cell.getColumnKey();
        String rowKey = cell.getRowKey();
        String value = cell.getValue();

        System.out.println(String.format("%s-%s-%s", rowKey, columnKey, value));
    });
}
项目:dremio-oss    文件:ImmutableCollectionSerializers.java   
public static void register(final Kryo kryo) {
  // register list
  final ImmutableListSerializer serializer = new ImmutableListSerializer();
  kryo.register(ImmutableList.class, serializer);
  kryo.register(ImmutableList.of().getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1)).getClass(), serializer);
  kryo.register(ImmutableList.of(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)).subList(1, 2).getClass(), serializer);
  kryo.register(ImmutableList.of().reverse().getClass(), serializer);
  kryo.register(Lists.charactersOf("dremio").getClass(), serializer);

  final HashBasedTable baseTable = HashBasedTable.create();
  baseTable.put(Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3));
  baseTable.put(Integer.valueOf(4), Integer.valueOf(5), Integer.valueOf(6));
  ImmutableTable table = ImmutableTable.copyOf(baseTable);
  kryo.register(table.values().getClass(), serializer);
}
项目:CustomWorldGen    文件:BlockStateContainer.java   
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);
    }
}
项目:bioasq    文件:ClassifierPredictor.java   
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  String candidateProviderName = UimaContextHelper
          .getConfigParameterStringValue(context, "candidate-provider");
  candidateProvider = ProviderCache.getProvider(candidateProviderName, CandidateProvider.class);
  String scorerNames = UimaContextHelper.getConfigParameterStringValue(context, "scorers");
  scorers = ProviderCache.getProviders(scorerNames, Scorer.class).stream()
          .map(scorer -> (Scorer<? super T>) scorer).collect(toList());
  String classifierName = UimaContextHelper.getConfigParameterStringValue(context, "classifier");
  classifier = ProviderCache.getProvider(classifierName, ClassifierProvider.class);
  if ((featureFilename = UimaContextHelper.getConfigParameterStringValue(context, "feature-file",
          null)) != null) {
    feat2value = HashBasedTable.create();
  }
}
项目:bioasq    文件:CVPredictLoader.java   
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  String candidateProviderName = UimaContextHelper
          .getConfigParameterStringValue(context, "candidate-provider");
  candidateProvider = ProviderCache.getProvider(candidateProviderName, CandidateProvider.class);
  // load cv
  String cvPredictFile = UimaContextHelper.getConfigParameterStringValue(context,
          "cv-predict-file");
  List<String> lines;
  try {
    lines = Resources.readLines(getClass().getResource(cvPredictFile), Charsets.UTF_8);
  } catch (IOException e) {
    throw new ResourceInitializationException(e);
  }
  qid2uri2score = HashBasedTable.create();
  lines.stream().map(line -> line.split("\t"))
          .forEach(segs -> qid2uri2score.put(segs[0], segs[1], Double.parseDouble(segs[2])));
}
项目:asglogic    文件:TableSynthesis.java   
protected EspressoTable createEspressoTable() {
    int num = stategraph.getAllSignals().size();
    if(resetname != null) {
        num++;
    }
    int i = 0;
    String[] inputs = new String[num];
    if(resetname != null) {
        inputs[i++] = resetname;
    }
    for(Signal sig : stategraph.getAllSignals()) {
        inputs[i++] = sig.getName();
    }
    Table<EspressoTerm, String, EspressoValue> table = HashBasedTable.create();

    fillTable(num, inputs, table);

    return new EspressoTable(inputs, table);
}
项目:factions-top    文件:ChunkLoader.java   
private Table<Integer, Material, Integer> loadChunkMaterial() throws SQLException {
    Table<Integer, Material, Integer> target = HashBasedTable.create();
    ResultSet resultSet = selectChunkMaterial.executeQuery();

    while (resultSet.next()) {
        int id = resultSet.getInt("id");
        int chunkId = resultSet.getInt("chunk_id");
        int materialId = resultSet.getInt("material_id");
        int count = resultSet.getInt("count");

        identityCache.setChunkMaterialId(chunkId, materialId, id);
        identityCache.getMaterial(materialId).ifPresent(material ->
                target.put(chunkId, material, count));
    }

    resultSet.close();
    return target;
}
项目:factions-top    文件:ChunkLoader.java   
private Table<Integer, EntityType, Integer> loadChunkSpawner() throws SQLException {
    Table<Integer, EntityType, Integer> target = HashBasedTable.create();
    ResultSet resultSet = selectChunkSpawner.executeQuery();

    while (resultSet.next()) {
        int id = resultSet.getInt("id");
        int chunkId = resultSet.getInt("chunk_id");
        int spawnerId = resultSet.getInt("spawner_id");
        int count = resultSet.getInt("count");

        identityCache.setChunkSpawnerId(chunkId, spawnerId, id);
        identityCache.getSpawner(spawnerId).ifPresent(spawner ->
                target.put(chunkId, spawner, count));
    }

    resultSet.close();
    return target;
}
项目:factions-top    文件:ChunkLoader.java   
private Table<Integer, WorthType, Double> loadChunkWorth() throws SQLException {
    Table<Integer, WorthType, Double> target = HashBasedTable.create();
    ResultSet resultSet = selectChunkWorth.executeQuery();

    while (resultSet.next()) {
        int id = resultSet.getInt("id");
        int chunkId = resultSet.getInt("chunk_id");
        int worthId = resultSet.getInt("worth_id");
        double worth = resultSet.getDouble("worth");

        identityCache.setChunkWorthId(chunkId, worthId, id);
        identityCache.getWorthType(worthId).ifPresent(worthType ->
                target.put(chunkId, worthType, worth));
    }

    resultSet.close();
    return target;
}
项目:fiat    文件:RedisPermissionsRepository.java   
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;
}
项目:twill    文件:RunningContainers.java   
RunningContainers(TwillRuntimeSpecification twillRuntimeSpec, String appId, TwillRunResources appMasterResources,
                  ZKClient zookeeperClient, Location applicationLocation,
                  Map<String, RuntimeSpecification> runnables,
                  EventHandler eventHandler) {
  containers = HashBasedTable.create();
  runnableInstances = Maps.newHashMap();
  completedContainerCount = Maps.newHashMap();
  startSequence = Lists.newLinkedList();
  containerLock = new ReentrantLock();
  containerChange = containerLock.newCondition();
  resourceReport = new DefaultResourceReport(appId, appMasterResources);
  zkClient = zookeeperClient;
  containerStats = HashMultimap.create();
  this.applicationLocation = applicationLocation;
  this.runnableNames = runnables.keySet();
  this.logLevels = new TreeMap<>();
  this.maxRetries = Maps.newHashMap(twillRuntimeSpec.getMaxRetries());
  this.numRetries = Maps.newHashMap();
  this.eventHandler = eventHandler;
}
项目:twill    文件:YarnTwillRunnerService.java   
/**
 * Creates an instance.
 *
 * @param config Configuration of the yarn cluster
 * @param zkConnect ZooKeeper connection string
 * @param locationFactory Factory to create {@link Location} instances that are readable and writable by this service
 */
public YarnTwillRunnerService(YarnConfiguration config, String zkConnect, LocationFactory locationFactory) {
  this.yarnConfig = config;
  this.locationFactory = locationFactory;
  this.zkClientService = getZKClientService(zkConnect);
  this.controllers = HashBasedTable.create();
  this.serviceDelegate = new AbstractIdleService() {
    @Override
    protected void startUp() throws Exception {
      YarnTwillRunnerService.this.startUp();
    }

    @Override
    protected void shutDown() throws Exception {
      YarnTwillRunnerService.this.shutDown();
    }
  };
}
项目:excel2javabeans    文件:ExcelImages.java   
private static Table<Integer, Integer, ImageData> readAllCellImages(HSSFPatriarch patriarch, Sheet sheet) {
    val images = HashBasedTable.<Integer, Integer, ImageData>create();
    val allPictures = sheet.getWorkbook().getAllPictures();
    for (val shape : patriarch.getChildren()) {
        if (!(shape instanceof HSSFPicture && shape.getAnchor() instanceof HSSFClientAnchor)) continue;

        val picture = (HSSFPicture) shape;
        val imageData = createImageData(allPictures.get(picture.getPictureIndex() - 1));

        val axisRow = computeAxisRowIndex(sheet, picture);
        val axisCol = computeAxisColIndex(sheet, picture);

        images.put(axisRow, axisCol, imageData);
    }

    return images;
}
项目:excel2javabeans    文件:ExcelImages.java   
private static Table<Integer, Integer, ImageData> readAllCellImages(XSSFDrawing drawing, Sheet sheet) {
    val images = HashBasedTable.<Integer, Integer, ImageData>create();
    for (val shape : drawing.getShapes()) {
        if (!(shape instanceof XSSFPicture)) continue;

        val picture = (XSSFPicture) shape;
        val imageData = createImageData(picture.getPictureData());

        val axisRow = computeAxisRowIndex(sheet, picture);
        val axisCol = computeAxisColIndex(sheet, picture);

        images.put(axisRow, axisCol, imageData);
    }

    return images;
}
项目:hybris-connector    文件:GenderProvider.java   
@Override
protected HashBasedTable<Optional<String>, Optional<Locale>, String> getAttributeValue(final Collection<Locale> locales,
        final ProductModel product, final MetaAttributeData metaAttribute)
{
    final HashBasedTable<Optional<String>, Optional<Locale>, String> table = HashBasedTable.create();
    if (product instanceof ApparelProductModel)
    {
        final List<Gender> genders = ((ApparelProductModel) product).getGenders();

        if (genders != null && !genders.isEmpty())
        {
            for (final Gender gender : genders)
            {
                addValues(table, null, gender.getCode(), metaAttribute);
            }
        }
    }
    return table;
}
项目:hybris-connector    文件:AbstractAttributeProvider.java   
@Override
public Collection<FhAttributeData> getAttribute(final ProductModel product, final MetaAttributeData metaAttribute,
        final Collection<Locale> locales)
{

    final HashBasedTable<Optional<String>, Optional<Locale>, String> values = getAttributeValue(locales, product,
            metaAttribute);

    if (values != null && !values.isEmpty())
    {
        final FhAttributeData attributeData = new FhAttributeData(metaAttribute.getBaseType());
        attributeData.setAttributeId(metaAttribute.getAttributeId());
        attributeData.setItemId(getSanitizeIdStrategy().sanitizeId(product.getCode()));
        attributeData.setValues(values);
        return Arrays.asList(attributeData);
    }
    return Collections.emptyList();
}
项目:hybris-connector    文件:ImageUrlProvider.java   
@Override
protected HashBasedTable<Optional<String>, Optional<Locale>, String> getAttributeValue(final Collection<Locale> locales,
        final ProductModel product, final MetaAttributeData metaAttribute)
{
    final HashBasedTable<Optional<String>, Optional<Locale>, String> table = HashBasedTable.create();

    final MediaFormatModel mediaFormatModel = getMediaService().getFormat(getMediaFormat());
    if (mediaFormatModel != null)
    {
        final MediaModel media = findMedia(product, mediaFormatModel);
        if (media != null)
        {
            addValues(table, null, media.getURL(), metaAttribute);
        }

    }

    return table;
}
项目:SQLIDetectionDriver    文件:SQLInjectionRepositoryH2.java   
@Override
public Collection<SQLInjectionAnalyzerEntry> getEntries() throws IOException {
    failIfClosed();
    List<SQLInjectionAnalyzerEntry> uncombinedEntries = getUncombinedEntriesFromDB();
    Table<String, String, SQLInjectionAnalyzerEntry> buffer = HashBasedTable.create();

    uncombinedEntries.stream()
            .forEach((e) -> {
                SQLInjectionAnalyzerEntry oldEntry = buffer.get(e.getEntryPoint(), e.getStatement());
                if (oldEntry != null) {
                    oldEntry.mergeStatementCall(e);
                } else {
                    buffer.put(e.getEntryPoint(), e.getStatement(), e);
                }
            });
    return Collections.unmodifiableCollection(buffer.values());
}
项目:beam    文件:ApexStateInternals.java   
@Override
public ApexStateInternals<K> stateInternalsForKey(K key) {
  final Slice keyBytes;
  try {
    keyBytes = (key != null) ? new Slice(CoderUtils.encodeToByteArray(keyCoder, key)) :
      new Slice(null);
  } catch (CoderException e) {
    throw new RuntimeException(e);
  }
  HashBasedTable<String, String, byte[]> stateTable = perKeyState.get(keyBytes);
  if (stateTable == null) {
    stateTable = HashBasedTable.create();
    perKeyState.put(keyBytes, stateTable);
  }
  return new ApexStateInternals<>(key, stateTable);
}
项目:guava-demo    文件:TableSample.java   
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}

}
项目:turnus    文件:TraceEvaluator.java   
/**
 * Constructor. Create a new trace builder.
 * 
 * @param traceFile
 * @throws TurnusException
 */
public TraceEvaluator(Network network, File traceFile) throws TurnusException {
    try {
        writer = new TraceWriter(traceFile);
        writer.start();
    } catch (TurnusException e) {
        throw e;
    }

    this.network = network;

    lastSharedVarStore = new HashMap<>();
    lastSharedVarLoad = new HashMap<>();
    lastScheduledFsm = new HashMap<>();
    lastVarStore = HashBasedTable.create();
    lastVarLoad = HashBasedTable.create();
    lastPortWrite = HashBasedTable.create();
    lastPortRead = HashBasedTable.create();
    actionsFirings = HashMultiset.create();
    actionsIncomings = HashMultiset.create();
    actionsOutgoings = HashMultiset.create();
    dependenciesKind = HashMultiset.create();

}
项目:turnus    文件:AverageTraceWeighter.java   
/**
 * Create a weighter (average values) given the network weights
 * 
 * @param networkWeights
 */
public AverageTraceWeighter(NetworkWeight networkWeights) {
    this.networkWeights = networkWeights;

    weightTable = HashBasedTable.create();
    varianceTable = HashBasedTable.create();
    for (Cell<String, String, ClockCycles> cell : networkWeights.asTable().cellSet()) {
        String actor = cell.getRowKey();
        String action = cell.getColumnKey();
        ClockCycles w = cell.getValue();

        double avg = w.getMeanClockCycles();
        double min = Math.min(w.getMinClockCycles(), avg);
        double max = Math.max(avg, w.getMaxClockCycles());
        double variance = Math.pow(((max - min) / 6.0), 2);

        weightTable.put(actor, action, avg);
        varianceTable.put(actor, action, variance);
    }
}
项目:turnus    文件:NormalDistributionTraceWeighter.java   
/**
 * Create a normal distribution weighter given the network weights
 * 
 * @param networkWeights
 */
public NormalDistributionTraceWeighter(NetworkWeight networkWeights) {
    this.networkWeights = networkWeights;

    weightTable = HashBasedTable.create();
    varianceTable = HashBasedTable.create();
    for (Cell<String, String, ClockCycles> cell : networkWeights.asTable().cellSet()) {
        String actor = cell.getRowKey();
        String action = cell.getColumnKey();
        ClockCycles w = cell.getValue();

        double avg = w.getMeanClockCycles();
        double min = Math.min(w.getMinClockCycles(), avg);
        double max = Math.max(avg, w.getMaxClockCycles());

        double weight = (min + 4 * avg + max) / 6.0;
        double variance = Math.pow(((max - min) / 6.0), 2);

        weightTable.put(actor, action, weight);
        varianceTable.put(actor, action, variance);
    }
}
项目:ALEA    文件:SpliceJunctionHelper.java   
/**
 * 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());
}
项目:ALEA    文件:AbstractConsensusCalculator.java   
protected static Table<Character, Character, Character> getDegeneracyTable() {
    if (degeneracyTable == null) {
        degeneracyTable = HashBasedTable.create(5, 5);
        Map<String, String> iupacMap = ParsingUtils.loadIUPACMap();
        for (String s : iupacMap.values()) {
            s = s.replace("[", "").replace("]", "").toLowerCase();
            //System.out.println(s);
            String[] tokens = s.split(",");
            if (tokens.length != 3) continue;
            char a = tokens[1].trim().charAt(0);
            char b = tokens[2].trim().charAt(0);
            char c = tokens[0].trim().charAt(0);
            degeneracyTable.put(a, b, c);
            degeneracyTable.put(b, a, c);
        }
    }
    return degeneracyTable;
}
项目:keystone4j    文件:FileScanner.java   
public Table<Type, String, String> read() throws IOException {
    logger.debug("Readig from file.");
    Table<Type, String, String> table = HashBasedTable.create();
    Scanner scanner = new Scanner(url.openStream());
    try {
        Config.Type type = Config.Type.keystone_authtoken;
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (!line.startsWith("#") && !line.isEmpty()) {
                if (line.startsWith("[") && line.endsWith("]")) {
                    type = Config.Type.valueOf(line.substring(1, line.length() - 1));
                    continue;
                }
                String[] split = line.split("=", 2);
                if (split.length == 2) {
                    table.put(type, split[0].trim(), split[1].trim());
                }
            }
        }
    } finally {
        scanner.close();
    }
    logger.debug("Text read in: " + table);
    return table;
}
项目:keystone4j    文件:FileScanner.java   
public Table<Type, String, String> read() throws IOException {
    logger.debug("Readig from file.");
    Table<Type, String, String> table = HashBasedTable.create();
    Scanner scanner = new Scanner(url.openStream());
    try {
        Config.Type type = Config.Type.DEFAULT;
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (!line.startsWith("#") && !line.isEmpty()) {
                if (line.startsWith("[") && line.endsWith("]")) {
                    type = Config.Type.valueOf(line.substring(1, line.length() - 1));
                    continue;
                }
                String[] split = line.split("=", 2);
                if (split.length == 2) {
                    table.put(type, split[0].trim(), split[1].trim());
                }
            }
        }
    } finally {
        scanner.close();
    }
    logger.debug("Text read in: " + table);
    return table;
}
项目:recalot.com    文件:SparseTensor.java   
/**
 * 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);
}
项目:EasySRL    文件:ChartCell.java   
public ChartCellNbestFactory(final int nbest, final double nbestBeam, final int maxSentenceLength,
        final Collection<Category> categories) {
    super();
    this.nbest = nbest;
    this.nbestBeam = nbestBeam;
    final Random randomGenerator = new Random();

    // Build a hash for every possible dependency
    categoryToArgumentToHeadToModifierToHash = HashBasedTable.create();
    for (final Category c : categories) {
        for (int i = 1; i <= c.getNumberOfArguments(); i++) {
            final int[][] array = new int[maxSentenceLength][maxSentenceLength];
            categoryToArgumentToHeadToModifierToHash.put(c, i, array);
            for (int head = 0; head < maxSentenceLength; head++) {
                for (int child = 0; child < maxSentenceLength; child++) {
                    array[head][child] = randomGenerator.nextInt();
                }
            }
        }
    }
}