Example usage for com.google.common.collect Tables newCustomTable

List of usage examples for com.google.common.collect Tables newCustomTable

Introduction

In this page you can find the example usage for com.google.common.collect Tables newCustomTable.

Prototype

@Beta
public static <R, C, V> Table<R, C, V> newCustomTable(Map<R, Map<C, V>> backingMap,
        Supplier<? extends Map<C, V>> factory) 

Source Link

Document

Creates a table that uses the specified backing map and factory.

Usage

From source file:org.clueminer.scatter.matrix.ScatterMatrixPanel.java

public static Table<Integer, String, LegendEntry> newTable() {
    return Tables.newCustomTable(Maps.<Integer, Map<String, LegendEntry>>newHashMap(),
            new Supplier<Map<String, LegendEntry>>() {
                @Override/*from  w  w w .j av  a  2 s.  com*/
                public Map<String, LegendEntry> get() {
                    return Maps.newHashMap();
                }
            });
}

From source file:com.github.rinde.rinsim.geom.TableGraph.java

/**
 * Create a new empty graph.//  w  ww.j  a  v a 2  s  . com
 */
public TableGraph() {
    data = Tables.newCustomTable(new LinkedHashMap<Point, Map<Point, Connection<E>>>(),
            new LinkedHashMapFactory<Connection<E>>());
}

From source file:com.github.rinde.rinsim.geom.MultimapGraph.java

/**
 * Instantiates a new graph using the specified multimap.
 * @param map The multimap that is copied into this new graph.
 *//*from   ww  w. j  a  va 2  s  .c o m*/
public MultimapGraph(Multimap<Point, Point> map) {
    multimap = LinkedHashMultimap.create(map);
    lazyConnectionTable = Tables.newCustomTable(new LinkedHashMap<Point, Map<Point, Connection<E>>>(),
            new LinkedHashMapFactory<Connection<E>>());
    deadEndNodes = new HashSet<>();
    deadEndNodes.addAll(multimap.values());
    deadEndNodes.removeAll(multimap.keySet());
}

From source file:org.clueminer.clustering.benchmark.consensus.ConsensusRun.java

private void createTable() {
    table = Tables.newCustomTable(Maps.<String, Map<String, Double>>newHashMap(),
            new Supplier<Map<String, Double>>() {
                @Override/* w  ww  .j a va2  s  .  c  o  m*/
                public Map<String, Double> get() {
                    return Maps.newHashMap();
                }
            });
}

From source file:com.google.devtools.build.lib.profiler.statistics.PhaseVfsStatistics.java

public PhaseVfsStatistics(ProfilePhase phase) {
    this.phase = phase;
    this.statistics = Tables.newCustomTable(new EnumMap<ProfilerTask, Map<String, Stat>>(ProfilerTask.class),
            new Supplier<Map<String, Stat>>() {
                @Override/*  w w  w  . j a va  2  s  .c o  m*/
                public Map<String, Stat> get() {
                    return new HashMap<>();
                }
            });
}

From source file:org.clueminer.eval.external.AdjustedRandCorrected.java

public Table<String, String, Integer> newTable() {
    return Tables.newCustomTable(Maps.<String, Map<String, Integer>>newHashMap(),
            new Supplier<Map<String, Integer>>() {
                @Override//  w  w  w . ja  v  a  2s.  c  om
                public Map<String, Integer> get() {
                    return Maps.newHashMap();
                }
            });
}

From source file:co.cask.cdap.data2.dataset2.InMemoryDatasetFramework.java

@Inject
public InMemoryDatasetFramework(DatasetDefinitionRegistryFactory registryFactory,
        @Named("defaultDatasetModules") Map<String, DatasetModule> defaultModules,
        CConfiguration configuration) {// w w  w  .  ja  va  2s  .  co m
    this.registryFactory = registryFactory;
    this.allowDatasetUncheckedUpgrade = configuration.getBoolean(Constants.Dataset.DATASET_UNCHECKED_UPGRADE);

    this.namespaces = Sets.newHashSet();
    this.nonDefaultTypes = HashMultimap.create();
    this.instances = HashBasedTable.create();
    this.registries = Maps.newHashMap();
    // the order in which module classes are inserted is important,
    // so we use a table where Map<Id.DatasetModule, String> is a LinkedHashMap
    Map<Id.Namespace, Map<Id.DatasetModule, String>> backingMap = Maps.newHashMap();
    this.moduleClasses = Tables.newCustomTable(backingMap, new Supplier<Map<Id.DatasetModule, String>>() {
        @Override
        public Map<Id.DatasetModule, String> get() {
            return Maps.newLinkedHashMap();
        }
    });

    // add default dataset modules to system namespace
    namespaces.add(Constants.SYSTEM_NAMESPACE_ID);
    DatasetDefinitionRegistry systemRegistry = registryFactory.create();
    for (Map.Entry<String, DatasetModule> entry : defaultModules.entrySet()) {
        LOG.info("Adding Default module {} to system namespace", entry.getKey());
        String moduleName = entry.getKey();
        DatasetModule module = entry.getValue();
        entry.getValue().register(systemRegistry);
        // keep track of default module classes. These are used when creating registries for other namespaces,
        // which need to register system classes too.
        String moduleClassName = DatasetModules.getDatasetModuleClass(module).getName();
        Id.DatasetModule moduleId = Id.DatasetModule.from(Constants.SYSTEM_NAMESPACE_ID, moduleName);
        moduleClasses.put(Constants.SYSTEM_NAMESPACE_ID, moduleId, moduleClassName);
    }
    registries.put(Constants.SYSTEM_NAMESPACE_ID, systemRegistry);

    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    readLock = readWriteLock.readLock();
    writeLock = readWriteLock.writeLock();
}

From source file:net.awairo.mcmod.spawnchecker.presetmode.spawncheck.SlimeSpawnChecker.java

private static Table<Integer, Integer, Boolean> createKeytable() {
    final Map<Integer, Map<Integer, Boolean>> backingMap = new CachedMap<>();
    final Supplier<Map<Integer, Boolean>> factory = CachedMap.supplier();

    return Tables.newCustomTable(backingMap, factory);
}

From source file:org.terasoluna.gfw.common.codelist.i18n.SimpleI18nCodeList.java

/**
 * create table which consist of {@link LinkedHashMap} factory.
 * @return table//from  ww  w .  ja v  a2  s. c o  m
 */
private Table<Locale, String, String> createTable() {
    Map<Locale, Map<String, String>> backingMap = Maps.newLinkedHashMap();
    Table<Locale, String, String> table = Tables.newCustomTable(backingMap, LINKED_HASH_MAP_SUPPLIER);
    return table;
}