com.google.common.collect.Tables Java Examples
The following examples show how to use
com.google.common.collect.Tables.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MergerResourceRepositoryV2.java From NBANDROID-V2 with Apache License 2.0 | 5 votes |
@Override public Table<ResourceNamespace, ResourceType, ResourceValueMap> getConfiguredResources( @NonNull FolderConfiguration referenceConfig) { synchronized (ITEM_MAP_LOCK) { Set<ResourceNamespace> namespaces = getNamespaces(); Map<ResourceNamespace, Map<ResourceType, ResourceValueMap>> backingMap; if (KnownNamespacesMap.canContainAll(namespaces)) { backingMap = new KnownNamespacesMap<>(); } else { backingMap = new HashMap<>(); } Table<ResourceNamespace, ResourceType, ResourceValueMap> table = Tables.newCustomTable(backingMap, () -> new EnumMap<>(ResourceType.class)); for (ResourceNamespace namespace : namespaces) { // TODO(namespaces): Move this method to ResourceResolverCache. // For performance reasons don't mix framework and non-framework resources since // they have different life spans. for (ResourceType type : ResourceType.values()) { // get the local results and put them in the map table.put( namespace, type, getConfiguredResources(namespace, type, referenceConfig)); } } return table; } }
Example #2
Source File: TableView.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
@Override public Set<Cell<R, C, V>> cellSet() { return new AbstractSet<Cell<R, C, V>>() { @Override public int size() { return TableView.this.size(); } @Override public boolean isEmpty() { return TableView.this.isEmpty(); } @Override public boolean contains(Object o) { if(!(o instanceof Cell)) return false; final Cell cell = (Cell) o; return Objects.equals(get(cell.getRowKey(), cell.getColumnKey()), cell.getValue()); } @Override public Stream<Cell<R, C, V>> stream() { return map.entrySet() .stream() .flatMap(row -> row.getValue() .entrySet() .stream() .map(col -> Tables.immutableCell(row.getKey(), col.getKey(), col.getValue()))); } @Override public Spliterator<Cell<R, C, V>> spliterator() { return stream().spliterator(); } @Override public Iterator<Cell<R, C, V>> iterator() { return Spliterators.iterator(spliterator()); } }; }
Example #3
Source File: InlineTableUtil.java From jpmml-evaluator with GNU Affero General Public License v3.0 | 4 votes |
@Override public Table<Integer, String, Object> load(InlineTable inlineTable){ return Tables.unmodifiableTable(parse(inlineTable)); }
Example #4
Source File: BDDReachabilityUtils.java From batfish with Apache License 2.0 | 2 votes |
/** * Returns an immutable copy of the input table that has been materialized in transposed form. * * <p>Use this instead of {@link Tables#transpose(Table)} if the result will be iterated on in * row-major order. Transposing the table alone does not change the row-major vs column-major * internal representation so the performance of row-oriented operations is abysmal. Instead, we * need to actually materialize the transposed representation. */ public static <R, C, V> Table<C, R, V> transposeAndMaterialize(Table<R, C, V> edgeTable) { return ImmutableTable.copyOf(Tables.transpose(edgeTable)); }