Java 类com.google.common.collect.Table.Cell 实例源码

项目:guava-mock    文件:TablesTest.java   
public void testToTable() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:guava-mock    文件:TablesTest.java   
public void testToTableNullMerge() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          (Integer v1, Integer v2) -> null,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          ImmutableTable.of(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("one", "uno", 2));
}
项目:guava-mock    文件:TablesTest.java   
public void testToTableMerging() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          Integer::sum,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:guava-mock    文件:ImmutableTableTest.java   
public void testToImmutableTable() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:guava-mock    文件:ImmutableTableTest.java   
public void testToImmutableTableMerging() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(
          Cell::getRowKey, Cell::getColumnKey, Cell::getValue, Integer::sum);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:googles-monorepo-demo    文件:TablesTest.java   
public void testToTable() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:googles-monorepo-demo    文件:TablesTest.java   
public void testToTableNullMerge() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          (Integer v1, Integer v2) -> null,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          ImmutableTable.of(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("one", "uno", 2));
}
项目:googles-monorepo-demo    文件:TablesTest.java   
public void testToTableMerging() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          Integer::sum,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:googles-monorepo-demo    文件:ImmutableTableTest.java   
public void testToImmutableTable() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:googles-monorepo-demo    文件:ImmutableTableTest.java   
public void testToImmutableTableMerging() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(
          Cell::getRowKey, Cell::getColumnKey, Cell::getValue, Integer::sum);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:famf    文件:SparseMatrix.java   
/**
 * Construct a sparse matrix with CRS structures (CCS structure optional).
 * 
 * @deprecated I don't recommend to use this method as it (takes time and)
 *             is better to constructe the column structure at the time when
 *             you construct the row structure (of data table). This method
 *             is put here (as an example) to show how to construct column
 *             structure according to the data table.
 */
public SparseMatrix(int rows, int cols,
        Table<Integer, Integer, Float> dataTable, boolean isCCSUsed) {
    numRows = rows;
    numColumns = cols;

    Multimap<Integer, Integer> colMap = null;

    if (isCCSUsed) {
        colMap = HashMultimap.create();
        for (Cell<Integer, Integer, Float> cell : dataTable.cellSet())
            colMap.put(cell.getColumnKey(), cell.getRowKey());
    }

    construct(dataTable, colMap);
}
项目:Rapture    文件:FoldNode.java   
private ReflexValue accumMatrix(IReflexDebugger debugger, Scope scope, ReflexValue arg) {
    Function f = functions.getFunction(FunctionFactory.createFunctionKey(fnName, 4)); // 2
                                                                              // parameters,
                                                                              // accumulator
                                                                              // and
    // array value
    ReflexValue accum = accumulator.evaluate(debugger, scope);
    ReflexSparseMatrixValue smv = arg.asMatrix();

    for (Cell<ReflexValue, ReflexValue, ReflexValue> cell : smv.getCells()) {
        List<ReflexNode> params = new ArrayList<ReflexNode>();
        params.add(new AtomNode(lineNumber, handler, scope, accum));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getRowKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getColumnKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getValue()));
        accum = f.invoke(debugger, lineNumber, params, functions, handler, scope, importHandler);
    }
    return accum;
}
项目:Rapture    文件:MapFnNode.java   
private ReflexValue mapMatrix(IReflexDebugger debugger, Scope scope, ReflexValue arg) {
    Function f = functions.getFunction(FunctionFactory.createFunctionKey(fnName, 3)); // 1
    // parameter
    ReflexSparseMatrixValue smv = arg.asMatrix();
    ReflexSparseMatrixValue mappedSmv = new ReflexSparseMatrixValue(2);
    mappedSmv.copyOrder(smv);
    for(Cell<ReflexValue, ReflexValue, ReflexValue> cell : smv.getCells()) {
        List<ReflexNode> params = new ArrayList<ReflexNode>();
        params.add(new AtomNode(lineNumber, handler, scope, cell.getRowKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getColumnKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getValue()));
        ReflexValue ret = f.invoke(debugger, lineNumber, params, functions, handler, scope, importHandler);
        // Ret should be a list [ row, col, value ]
        if (ret.isList()) {
            List<ReflexValue> mappedValues = ret.asList();
            if (mappedValues.size() == 3) {
                mappedSmv.set(mappedValues.get(0), mappedValues.get(1), mappedValues.get(2));
            }
        }
    }
    return new ReflexValue(mappedSmv);
}
项目:Rapture    文件:FilterFnNode.java   
private ReflexValue workOnMatrix(IReflexDebugger debugger, Scope scope, ReflexValue arg) {
    Function f = functions.getFunction(FunctionFactory.createFunctionKey(fnName, 3));
    ReflexSparseMatrixValue smb = arg.asMatrix();
    ReflexSparseMatrixValue filteredMatrix = new ReflexSparseMatrixValue(2);
    for(Cell<ReflexValue, ReflexValue, ReflexValue> cell : smb.getCells()) {
        List<ReflexNode> params = new ArrayList<ReflexNode>();
        params.add(new AtomNode(lineNumber, handler, scope, cell.getRowKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getColumnKey()));
        params.add(new AtomNode(lineNumber, handler, scope, cell.getValue()));
        ReflexValue innerRet = f.invoke(debugger, lineNumber, params, functions, handler, scope, importHandler);
        if (innerRet.isBoolean() && innerRet.asBoolean() == true) {
            filteredMatrix.set(cell.getRowKey(), cell.getColumnKey(), cell.getValue());
        }          
    }
    return new ReflexValue(filteredMatrix);
}
项目:JAADAS    文件:JimpleIDESolver.java   
public void dumpResults() {
    try {
        PrintWriter out = new PrintWriter(new FileOutputStream("ideSolverDump"+System.currentTimeMillis()+".csv"));
        List<String> res = new ArrayList<String>();
        for(Cell<Unit, D, V> entry: val.cellSet()) {
            SootMethod methodOf = (SootMethod) icfg.getMethodOf(entry.getRowKey());
            PatchingChain<Unit> units = methodOf.getActiveBody().getUnits();
            int i=0;
            for (Unit unit : units) {
                if(unit==entry.getRowKey())
                    break;
                i++;
            }

            res.add(methodOf+";"+entry.getRowKey()+"@"+i+";"+entry.getColumnKey()+";"+entry.getValue());
        }
        Collections.sort(res);
        for (String string : res) {
            out.println(string);
        }
        out.flush();
        out.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}
项目:JAADAS    文件:IDESolver.java   
public void run() {
    int sectionSize = (int) Math.floor(values.length / numThreads) + numThreads;
    for(int i = sectionSize * num; i < Math.min(sectionSize * (num+1),values.length); i++) {
        N n = values[i];
        for(N sP: icfg.getStartPointsOf(icfg.getMethodOf(n))) {                 
            Set<Cell<D, D, EdgeFunction<V>>> lookupByTarget;
            lookupByTarget = jumpFn.lookupByTarget(n);
            for(Cell<D, D, EdgeFunction<V>> sourceValTargetValAndFunction : lookupByTarget) {
                D dPrime = sourceValTargetValAndFunction.getRowKey();
                D d = sourceValTargetValAndFunction.getColumnKey();
                EdgeFunction<V> fPrime = sourceValTargetValAndFunction.getValue();
                synchronized (val) {
                    setVal(n,d,valueLattice.join(val(n,d),fPrime.computeTarget(val(sP,dPrime))));
                }
                flowFunctionApplicationCount++;
            }
        }
    }
}
项目:cerebro-layout    文件:JungCommunityComputer.java   
private void populateFromFlows(DynamicFlowGraph flowGraph) {
  int eid = 0;
  for(Cell<Integer, Integer, Integer> edge : flowGraph.getEdges()) {
    int from = edge.getRowKey();
    int to = edge.getColumnKey();
    if(!jungGraph.containsVertex(from)) {
      jungGraph.addVertex(from);
    }

    if(!jungGraph.containsVertex(to)) {
      jungGraph.addVertex(to);
    }

    int edgeCount = edge.getValue();

    for(int i = 0; i < edgeCount; i += 1) {
      jungGraph.addEdge(eid, from, to, EdgeType.DIRECTED);
      eid += 1;
    }
  }
}
项目:cerebro-layout    文件:Spine.java   
public void initGraphicGraph() {
  int uniqId = 0;
  for(Cell<Integer, Integer, Integer> edge : flowGraph.getEdges()) {
    double weight = edge.getValue();
    System.out.format("%s %s %s\n", edge.getRowKey(), edge.getColumnKey(), weight);
    String fromId = String.valueOf(edge.getRowKey());
    String toId = String.valueOf(edge.getColumnKey());

    Node from = this.addNode(fromId);
    Node to = this.addNode(toId);

    int id = uniqId++;
    addEdge(from, to, id);
  }

  weighEdges();
}
项目:cerebro-layout    文件:RossalExecCsvReader.java   
public DynamicFlowGraph readAll(File ... rossalCsvs) {
  DynamicFlowGraph graph = new DynamicFlowGraph();
  for(File csv : rossalCsvs) {
    if(csv == null || !csv.exists() || !csv.isFile() 
        || !csv.getName().endsWith(".csv")) {
      continue;
    }

    DynamicFlowGraph tempGraph = read(csv);
    for(Cell<Integer, Integer, Integer> edge : tempGraph.getEdges()) {
      int fromId = edge.getRowKey();
      SourceLineNode from = tempGraph.getNode(fromId);
      from = graph.addNode(SourceLineNode.clone(from));

      int toId = edge.getColumnKey();
      SourceLineNode to = tempGraph.getNode(toId);

      to = graph.addNode(SourceLineNode.clone(to));

      int count = edge.getValue();
      graph.addEdge(from, to, count);
    }
  }
  return graph;
}
项目:codebuff    文件:RegularImmutableTable.java   
/**
 * A factory that chooses the most space-efficient representation of the
 * table.
 */

private static final <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(Iterable<Cell<R, C, V>> cells, @Nullable Comparator<? super R> rowComparator, @Nullable Comparator<? super C> columnComparator) {
  Set<R> rowSpaceBuilder = new LinkedHashSet<R>();
  Set<C> columnSpaceBuilder = new LinkedHashSet<C>();
  ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
  for (Cell<R, C, V> cell : cells) {
    rowSpaceBuilder.add(cell.getRowKey());
    columnSpaceBuilder.add(cell.getColumnKey());
  }
  ImmutableSet<R> rowSpace = (rowComparator == null)
    ? ImmutableSet.copyOf(rowSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(rowComparator).immutableSortedCopy(rowSpaceBuilder));
  ImmutableSet<C> columnSpace = (columnComparator == null)
    ? ImmutableSet.copyOf(columnSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(columnComparator).immutableSortedCopy(columnSpaceBuilder));

  // use a dense table if more than half of the cells have values
  // TODO(gak): tune this condition based on empirical evidence
  return (cellList.size() > (((long) rowSpace.size() * columnSpace.size()) / 2)) ? new DenseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace) : new SparseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace);
}
项目:codebuff    文件:RegularImmutableTable.java   
/**
 * A factory that chooses the most space-efficient representation of the
 * table.
 */

private static final <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(Iterable<Cell<R, C, V>> cells, @Nullable Comparator<? super R> rowComparator, @Nullable Comparator<? super C> columnComparator) {
  Set<R> rowSpaceBuilder = new LinkedHashSet<R>();
  Set<C> columnSpaceBuilder = new LinkedHashSet<C>();
  ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
  for (Cell<R, C, V> cell : cells) {
    rowSpaceBuilder.add(cell.getRowKey());
    columnSpaceBuilder.add(cell.getColumnKey());
  }
  ImmutableSet<R> rowSpace = (rowComparator == null)
    ? ImmutableSet.copyOf(rowSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(rowComparator).immutableSortedCopy(rowSpaceBuilder));
  ImmutableSet<C> columnSpace = (columnComparator == null)
    ? ImmutableSet.copyOf(columnSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(columnComparator).immutableSortedCopy(columnSpaceBuilder));

  // use a dense table if more than half of the cells have values
  // TODO(gak): tune this condition based on empirical evidence
  return (cellList.size() > (((long) rowSpace.size() * columnSpace.size()) / 2)) ? new DenseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace) : new SparseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace);
}
项目:codebuff    文件:RegularImmutableTable.java   
/**
 * A factory that chooses the most space-efficient representation of the
 * table.
 */

private static final <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(Iterable<Cell<R, C, V>> cells, @Nullable Comparator<? super R> rowComparator, @Nullable Comparator<? super C> columnComparator) {
  Set<R> rowSpaceBuilder = new LinkedHashSet<R>();
  Set<C> columnSpaceBuilder = new LinkedHashSet<C>();
  ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
  for (Cell<R, C, V> cell : cells) {
    rowSpaceBuilder.add(cell.getRowKey());
    columnSpaceBuilder.add(cell.getColumnKey());
  }
  ImmutableSet<R> rowSpace =
    (rowComparator == null)
      ? ImmutableSet.copyOf(rowSpaceBuilder)
      : ImmutableSet.copyOf(Ordering.from(rowComparator).immutableSortedCopy(rowSpaceBuilder));
  ImmutableSet<C> columnSpace =
    (columnComparator == null)
      ? ImmutableSet.copyOf(columnSpaceBuilder)
      : ImmutableSet.copyOf(Ordering.from(columnComparator).immutableSortedCopy(columnSpaceBuilder));

  // use a dense table if more than half of the cells have values
  // TODO(gak): tune this condition based on empirical evidence
  return (cellList.size() > (((long) rowSpace.size() * columnSpace.size()) / 2)) ? new DenseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace) : new SparseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace);
}
项目:codebuff    文件:RegularImmutableTable.java   
/**
 * A factory that chooses the most space-efficient representation of the
 * table.
 */

private static final <R, C, V> RegularImmutableTable<R, C, V> forCellsInternal(Iterable<Cell<R, C, V>> cells, @Nullable Comparator<? super R> rowComparator, @Nullable Comparator<? super C> columnComparator) {
  Set<R> rowSpaceBuilder = new LinkedHashSet<R>();
  Set<C> columnSpaceBuilder = new LinkedHashSet<C>();
  ImmutableList<Cell<R, C, V>> cellList = ImmutableList.copyOf(cells);
  for (Cell<R, C, V> cell : cells) {
    rowSpaceBuilder.add(cell.getRowKey());
    columnSpaceBuilder.add(cell.getColumnKey());
  }
  ImmutableSet<R> rowSpace = (rowComparator == null)
    ? ImmutableSet.copyOf(rowSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(rowComparator).immutableSortedCopy(rowSpaceBuilder));
  ImmutableSet<C> columnSpace = (columnComparator == null)
    ? ImmutableSet.copyOf(columnSpaceBuilder)
    : ImmutableSet.copyOf(Ordering.from(columnComparator).immutableSortedCopy(columnSpaceBuilder));

  // use a dense table if more than half of the cells have values
  // TODO(gak): tune this condition based on empirical evidence
  return (cellList.size() > (((long) rowSpace.size() * columnSpace.size()) / 2)) ? new DenseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace) : new SparseImmutableTable<R, C, V>(cellList, rowSpace, columnSpace);
}
项目:turnus    文件:BufferSizeEditor.java   
@Override
public void modify(Object o, String property, Object value) {
    // int columnIndex = Arrays.asList(columnNames).indexOf(property);
    if (property.equals(columnNames[SIZE])) {
        String intString = (String) value;
        if (intString.matches("[+]?\\d+")) {
            TableItem item = (TableItem) o;
            @SuppressWarnings("unchecked")
            Cell<Pair<String, String>, Pair<String, String>, Integer> element = (Cell<Pair<String, String>, Pair<String, String>, Integer>) item
                    .getData();
            int oldValue = element.getValue();
            int newValue = Integer.parseInt(intString);
            if (oldValue != newValue) {
                Pair<String, String> src = element.getRowKey();
                Pair<String, String> tgt = element.getColumnKey();
                bufferSize.setSize(src.v1, src.v2, tgt.v1, tgt.v2, newValue);
                setDirty(true);
            }
            viewer.refresh();

        }
    }

}
项目:turnus    文件:FileExporterFactory.java   
/**
 * Get the set of supported input file extension for a given output file
 * extension
 * 
 * @param output
 *            the output file extension (with or without {@code "."})
 * @return the set of supported input file extensions (without {@code "."})
 */
public Set<String> getSupportedInputs(String output) {
    Set<String> inputs = new HashSet<>();

    // check not null
    if (output == null) {
        return inputs;
    } else if (output.startsWith(".")) { // clean the format
        output = output.replaceFirst(".", "");
    }

    for (Cell<String, String, FileExporter<?>> e : exporters.cellSet()) {
        if (e.getColumnKey().equals(output))
            inputs.add(e.getRowKey());
    }
    return inputs;
}
项目: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);
    }
}
项目:EasySRL    文件:AbstractParser.java   
public AbstractParser(final ParserBuilder<?> builder) {
    this.unaryRules = builder.getUnaryRules();
    this.seenRules = builder.getSeenRules();
    this.lexicalCategories = builder.getLexicalCategories();
    this.possibleRootCategories = ImmutableSet.copyOf(builder.getValidRootCategories());
    this.nbest = builder.getNbest();
    this.maxLength = builder.getMaxSentenceLength();
    this.binaryRules = builder.getCombinators();
    this.allowUnseenRules = builder.getAllowUnseenRules();
    this.normalForm = builder.getNormalForm();
    this.nbestBeam = builder.getNbestBeam();

    for (final Cell<Category, Category, List<RuleProduction>> entry : seenRules.ruleTable().cellSet()) {
        // Cache out all the rules in advance.
        getRules(entry.getRowKey(), entry.getColumnKey());
    }
}
项目:EasySRL    文件:ParallelCorpusReader.java   
private static Collection<SRLParse> getPropbankSection(final String section) throws IOException {
    final Table<String, Integer, TreebankParse> PTB = new PennTreebank().readCorpus(WSJ);
    final Table<String, Integer, SRLParse> srlParses = SRLParse.parseCorpus(PTB,
            Util.readFileLineByLine(new File(PROPBANK, "prop.txt")),
            USING_NOMBANK ? Util.readFileLineByLine(NOMBANK) : null);

    final Table<String, Integer, SRLParse> goldParses = TreeBasedTable.create();
    for (final Cell<String, Integer, TreebankParse> cell : PTB.cellSet()) {

        // Propbank files skip sentences with no SRL deps. Add a default
        // empty parse for all sentences.
        goldParses.put(cell.getRowKey(), cell.getColumnKey(), new SRLParse(cell.getValue().getWords()));
    }
    goldParses.putAll(srlParses);

    final Collection<SRLParse> result = new ArrayList<>();
    for (final Cell<String, Integer, SRLParse> entry : goldParses.cellSet()) {
        if (entry.getRowKey().startsWith("wsj_" + section)) {
            result.add(entry.getValue());
        }
    }
    return result;
}
项目:bue-common-open    文件:ProvenancedConfusionMatrix.java   
/**
 * Return a new {@code ProvenancedConfusionMatrix} containing only those provenance entries
 * matching the provided predicate.
 */
public ProvenancedConfusionMatrix<CellFiller> filteredCopy(Predicate<CellFiller> predicate) {
  final ImmutableTable.Builder<Symbol, Symbol, List<CellFiller>> newTable =
      ImmutableTable.builder();

  for (final Cell<Symbol, Symbol, List<CellFiller>> curCell : table.cellSet()) {
    final List<CellFiller> newFiller = FluentIterable.from(curCell.getValue())
        .filter(predicate).toList();
    if (!newFiller.isEmpty()) {
      newTable.put(curCell.getRowKey(), curCell.getColumnKey(), newFiller);
    }

  }

  return new ProvenancedConfusionMatrix<CellFiller>(newTable.build());
}
项目:guava    文件:TablesTest.java   
public void testToTable() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue, HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:guava    文件:TablesTest.java   
public void testToTableNullMerge() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          (Integer v1, Integer v2) -> null,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          ImmutableTable.of(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("one", "uno", 2));
}
项目:guava    文件:TablesTest.java   
public void testToTableMerging() {
  Collector<Cell<String, String, Integer>, ?, Table<String, String, Integer>> collector =
      Tables.toTable(
          Cell::getRowKey,
          Cell::getColumnKey,
          Cell::getValue,
          Integer::sum,
          HashBasedTable::create);
  Equivalence<Table<String, String, Integer>> equivalence =
      Equivalence.equals().<Cell<String, String, Integer>>pairwise().onResultOf(Table::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:guava    文件:ImmutableTableTest.java   
public void testToImmutableTable() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 2)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3));
}
项目:guava    文件:ImmutableTableTest.java   
public void testToImmutableTableMerging() {
  Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>> collector =
      ImmutableTable.toImmutableTable(
          Cell::getRowKey, Cell::getColumnKey, Cell::getValue, Integer::sum);
  Equivalence<ImmutableTable<String, String, Integer>> equivalence =
      Equivalence.equals()
          .<Cell<String, String, Integer>>pairwise()
          .onResultOf(ImmutableTable::cellSet);
  CollectorTester.of(collector, equivalence)
      .expectCollects(
          new ImmutableTable.Builder<String, String, Integer>()
              .put("one", "uno", 1)
              .put("two", "dos", 6)
              .put("three", "tres", 3)
              .build(),
          Tables.immutableCell("one", "uno", 1),
          Tables.immutableCell("two", "dos", 2),
          Tables.immutableCell("three", "tres", 3),
          Tables.immutableCell("two", "dos", 4));
}
项目:kidneyExchange    文件:MinWaitingTimeKepSolver.java   
private ImmutableTable<V, V, Double> getPrecedenceVariableValues(
    VariableSet.VariableExtractor variableExtractor) {
  ImmutableTable.Builder<V, V, Double> ans = ImmutableTable.builder();
  List<Cell<V, V, IloNumVar>> varsAsList = Lists
      .newArrayList(this.precedenceVariables.cellSet());
  IloNumVar[] varArray = new IloNumVar[varsAsList.size()];
  int i = 0;
  for (Cell<V, V, IloNumVar> cell : varsAsList) {
    varArray[i++] = cell.getValue();
  }
  double[] varVals;
  try {
    varVals = variableExtractor.getValuesVE(varArray);
  } catch (IloException e) {
    throw new RuntimeException(e);
  }
  for (int j = 0; j < varsAsList.size(); j++) {
    ans.put(varsAsList.get(j).getRowKey(), varsAsList.get(j).getColumnKey(),
        varVals[j]);
  }
  return ans.build();
}
项目:kidneyExchange    文件:MinWaitingTimeKepSolver.java   
private void printDeltaVars(VariableSet.VariableExtractor variableExtractor) {

    List<Cell<V, V, IloNumVar>> varsAsList = Lists
        .newArrayList(this.precedenceVariables.cellSet());
    IloNumVar[] varArray = new IloNumVar[varsAsList.size()];
    int i = 0;
    for (Cell<V, V, IloNumVar> cell : varsAsList) {
      varArray[i++] = cell.getValue();
    }
    double[] varVals;
    try {
      varVals = variableExtractor.getValuesVE(varArray);
    } catch (IloException e) {
      throw new RuntimeException(e);
    }
    for (int j = 0; j < varsAsList.size(); j++) {
      System.out.println(varsAsList.get(j).getRowKey() + ", "
          + varsAsList.get(j).getColumnKey() + " = " + varVals[j]);
    }
  }
项目:guava-mock    文件:Tables.java   
/**
 * Returns a {@link Collector} that accumulates elements into a {@code Table} created using the
 * specified supplier, whose cells are generated by applying the provided mapping functions to the
 * input elements. Cells are inserted into the generated {@code Table} in encounter order.
 *
 * <p>If multiple input elements map to the same row and column, the specified merging function is
 * used to combine the values. Like {@link
 * java.util.stream.Collectors#toMap(java.util.function.Function, java.util.function.Function,
 * BinaryOperator, java.util.function.Supplier)}, this Collector throws a {@code
 * NullPointerException} on null values returned from {@code valueFunction}, and treats nulls
 * returned from {@code mergeFunction} as removals of that row/column pair.
 *
 * @since 21.0
 */
public static <T, R, C, V, I extends Table<R, C, V>> Collector<T, ?, I> toTable(
    java.util.function.Function<? super T, ? extends R> rowFunction,
    java.util.function.Function<? super T, ? extends C> columnFunction,
    java.util.function.Function<? super T, ? extends V> valueFunction,
    BinaryOperator<V> mergeFunction,
    java.util.function.Supplier<I> tableSupplier) {
  checkNotNull(rowFunction);
  checkNotNull(columnFunction);
  checkNotNull(valueFunction);
  checkNotNull(mergeFunction);
  checkNotNull(tableSupplier);
  return Collector.of(
      tableSupplier,
      (table, input) ->
          merge(
              table,
              rowFunction.apply(input),
              columnFunction.apply(input),
              valueFunction.apply(input),
              mergeFunction),
      (table1, table2) -> {
        for (Table.Cell<R, C, V> cell2 : table2.cellSet()) {
          merge(table1, cell2.getRowKey(), cell2.getColumnKey(), cell2.getValue(), mergeFunction);
        }
        return table1;
      });
}
项目:guava-mock    文件:Tables.java   
@Override
public boolean equals(Object obj) {
  if (obj == this) {
    return true;
  }
  if (obj instanceof Cell) {
    Cell<?, ?, ?> other = (Cell<?, ?, ?>) obj;
    return Objects.equal(getRowKey(), other.getRowKey())
        && Objects.equal(getColumnKey(), other.getColumnKey())
        && Objects.equal(getValue(), other.getValue());
  }
  return false;
}
项目:guava-mock    文件:Tables.java   
Function<Cell<R, C, V1>, Cell<R, C, V2>> cellFunction() {
  return new Function<Cell<R, C, V1>, Cell<R, C, V2>>() {
    @Override
    public Cell<R, C, V2> apply(Cell<R, C, V1> cell) {
      return immutableCell(
          cell.getRowKey(), cell.getColumnKey(), function.apply(cell.getValue()));
    }
  };
}