本文整理匯總了Java中com.google.common.collect.Table.Cell類的典型用法代碼示例。如果您正苦於以下問題:Java Cell類的具體用法?Java Cell怎麽用?Java Cell使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Cell類屬於com.google.common.collect.Table包,在下文中一共展示了Cell類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testToTable
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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));
}
示例2: testToTableNullMerge
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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));
}
示例3: testToTableMerging
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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));
}
示例4: testToImmutableTable
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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));
}
示例5: testToImmutableTableMerging
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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));
}
示例6: SparseMatrix
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
/**
* 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);
}
示例7: accumMatrix
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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;
}
示例8: mapMatrix
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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);
}
示例9: workOnMatrix
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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);
}
示例10: dumpResults
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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();
}
}
示例11: run
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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++;
}
}
}
}
示例12: populateFromFlows
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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;
}
}
}
示例13: initGraphicGraph
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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();
}
示例14: readAll
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
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;
}
示例15: forCellsInternal
import com.google.common.collect.Table.Cell; //導入依賴的package包/類
/**
* 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);
}