/** * Constructs a new (empty) Counter. */ public IntCounter() { this(MapFactory.<E,MutableInteger>hashMapFactory()); }
/** * Pass in a MapFactory and the map it vends will back your Counter. * * @param mapFactory The Map this factory vends will back your Counter. */ public ClassicCounter(MapFactory<E,MutableDouble> mapFactory) { this.mapFactory = mapFactory; this.map = mapFactory.newMap(); }
public static <K1, K2> TwoDimensionalCounter<K1, K2> identityHashMapCounter() { return new TwoDimensionalCounter<>(MapFactory.<K1, ClassicCounter<K2>>identityHashMapFactory(), MapFactory.<K2, MutableDouble>identityHashMapFactory()); }
MapFactory.<String,MutableDouble>arrayMapFactory(): MapFactory.<String,MutableDouble>linkedHashMapFactory(); Counter<String> counts = new ClassicCounter<>(mapFactory); for (int i = 1; i < columns.length; i++) {
/** * Returns a new SemanticGraph which is a copy of the supplied SemanticGraph. * Both the nodes ({@link IndexedWord}s) and the edges (SemanticGraphEdges) * are copied. */ public SemanticGraph(SemanticGraph g) { graph = new DirectedMultiGraph<>(g.graph); roots = wordMapFactory.newSet(g.roots); }
/** * Copies a the current graph, but also sets the mapping from the old to new * graph. */ public SemanticGraph(SemanticGraph g, Map<IndexedWord, IndexedWord> prevToNewMap) { graph = new DirectedMultiGraph<>(outerMapFactory, innerMapFactory); if (prevToNewMap == null) { prevToNewMap = wordMapFactory.newMap(); } Set<IndexedWord> vertexes = g.vertexSet(); for (IndexedWord vertex : vertexes) { IndexedWord newVertex = new IndexedWord(vertex); newVertex.setCopyCount(vertex.copyCount()); addVertex(newVertex); prevToNewMap.put(vertex, newVertex); } roots = wordMapFactory.newSet(); for (IndexedWord oldRoot : g.getRoots()) { roots.add(prevToNewMap.get(oldRoot)); } for (SemanticGraphEdge edge : g.edgeIterable()) { IndexedWord newGov = prevToNewMap.get(edge.getGovernor()); IndexedWord newDep = prevToNewMap.get(edge.getDependent()); addEdge(newGov, newDep, edge.getRelation(), edge.getWeight(), edge.isExtra()); } }
public VariableStrings() { varsToStrings = ArrayMap.newArrayMap(); numVarsSet = new IntCounter<>(MapFactory.<String, MutableInteger>arrayMapFactory()); }
public static <K1, K2, V> TwoDimensionalMap<K1, K2, V> treeMap() { return new TwoDimensionalMap<>(MapFactory.<K1, Map<K2, V>>treeMapFactory(), MapFactory.<K2, V>treeMapFactory()); }
MapFactory.<String,MutableDouble>arrayMapFactory(): MapFactory.<String,MutableDouble>linkedHashMapFactory(); Counter<String> counts = new ClassicCounter<>(mapFactory); for (int i = 1; i < columns.length; i++) {
public SemanticGraph() { graph = new DirectedMultiGraph<>(outerMapFactory, innerMapFactory); roots = wordMapFactory.newSet(); }
public VariableStrings() { varsToStrings = ArrayMap.newArrayMap(); numVarsSet = new IntCounter<>(MapFactory.<String, MutableInteger>arrayMapFactory()); }
public static <K1, K2, V> TwoDimensionalMap<K1, K2, V> treeMap() { return new TwoDimensionalMap<>(MapFactory.<K1, Map<K2, V>>treeMapFactory(), MapFactory.<K2, V>treeMapFactory()); }
/** * Creates a new empty TwoDimensionalCollectionValuedMap which uses a HashMap as the * underlying Map. Does not treat Collections as immutable. * * @param cf a CollectionFactory which will be used to generate the * Collections in each mapping */ public TwoDimensionalCollectionValuedMap(CollectionFactory<V> cf) { this(MapFactory.<K2,Collection<V>>hashMapFactory(), cf, false); }
/** * Pass in a MapFactory and the map it vends will back your Counter. * * @param mapFactory The Map this factory vends will back your Counter. * @param initialCapacity initial capacity of the counter */ public ClassicCounter(MapFactory<E,MutableDouble> mapFactory, int initialCapacity) { this.mapFactory = mapFactory; this.map = mapFactory.newMap(initialCapacity); }
MapFactory.<String,MutableDouble>arrayMapFactory(): MapFactory.<String,MutableDouble>linkedHashMapFactory(); Counter<String> counts = new ClassicCounter<>(mapFactory); for (int i = 1; i < columns.length; i++) {
/** * @return true if the graph contains no cycles. */ public boolean isDag() { Set<IndexedWord> unused = wordMapFactory.newSet(); unused.addAll(vertexSet()); while (!unused.isEmpty()) { IndexedWord arbitrary = unused.iterator().next(); boolean result = isDagHelper(arbitrary, unused, wordMapFactory.newSet()); if (result) { return false; } } return true; }
public static <K1, K2, V> TwoDimensionalMap<K1, K2, V> identityHashMap() { return new TwoDimensionalMap<>(MapFactory.<K1, Map<K2, V>>identityHashMapFactory(), MapFactory.<K2, V>identityHashMapFactory()); }
public VariableStrings() { varsToStrings = ArrayMap.newArrayMap(); numVarsSet = new IntCounter<String>(MapFactory.<String, MutableInteger>arrayMapFactory()); }
public static <K1, K2, V> TwoDimensionalMap<K1, K2, V> treeMap() { return new TwoDimensionalMap<>(MapFactory.<K1, Map<K2, V>>treeMapFactory(), MapFactory.<K2, V>treeMapFactory()); }
/** * Creates a new empty CollectionValuedMap which uses a HashMap as the * underlying Map. Does not treat Collections as immutable. * * @param cf A CollectionFactory which will be used to generate the Collections * in each mapping */ public CollectionValuedMap(CollectionFactory<V> cf) { this(MapFactory.hashMapFactory(), cf, false); }