Skip to content

Commit cbab6a6

Browse files
johnmayegonw
authored andcommitted
This was a useful one, the "official" calculation is (int)1+(n/0.75) for the default load factor. However in all these cases we expected n to be small - say 100 or so. In which case 135 vs 200 (2*n) is fine.
1 parent 9d7940b commit cbab6a6

File tree

12 files changed

+21
-24
lines changed

12 files changed

+21
-24
lines changed

base/core/src/main/java/org/openscience/cdk/graph/GraphUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323
*/
2424
package org.openscience.cdk.graph;
2525

26-
import com.google.common.collect.Maps;
2726
import org.openscience.cdk.interfaces.IAtomContainer;
2827
import org.openscience.cdk.interfaces.IBond;
2928

29+
import java.util.HashMap;
3030
import java.util.Map;
3131
import java.util.Set;
3232

@@ -312,7 +312,7 @@ public static final class EdgeToBondMap {
312312
* @param n number of bonds expected
313313
*/
314314
private EdgeToBondMap(int n) {
315-
this.lookup = Maps.newHashMapWithExpectedSize(n);
315+
this.lookup = new HashMap<>(2*n);
316316
}
317317

318318
/**

base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/QueryStereoFilter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
package org.openscience.cdk.isomorphism;
2727

28-
import com.google.common.collect.Maps;
2928
import org.openscience.cdk.interfaces.IAtom;
3029
import org.openscience.cdk.interfaces.IAtomContainer;
3130
import org.openscience.cdk.interfaces.IBond;
@@ -38,6 +37,7 @@
3837
import org.openscience.cdk.isomorphism.matchers.QueryBond;
3938

4039
import java.util.Arrays;
40+
import java.util.HashMap;
4141
import java.util.Map;
4242
import java.util.function.Predicate;
4343

@@ -372,7 +372,7 @@ private int otherIndex(int i) {
372372
* @return the index/lookup of atoms to the index they appear
373373
*/
374374
private static Map<IAtom, Integer> indexAtoms(IAtomContainer container) {
375-
Map<IAtom, Integer> map = Maps.newHashMapWithExpectedSize(container.getAtomCount());
375+
Map<IAtom, Integer> map = new HashMap<>(2*container.getAtomCount());
376376
for (int i = 0; i < container.getAtomCount(); i++)
377377
map.put(container.getAtom(i), i);
378378
return map;

base/isomorphism/src/main/java/org/openscience/cdk/isomorphism/StereoMatch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package org.openscience.cdk.isomorphism;
2626

27-
import com.google.common.collect.Maps;
2827
import org.openscience.cdk.interfaces.IAtom;
2928
import org.openscience.cdk.interfaces.IAtomContainer;
3029
import org.openscience.cdk.interfaces.IBond;
@@ -33,6 +32,7 @@
3332
import org.openscience.cdk.interfaces.ITetrahedralChirality;
3433

3534
import java.util.Arrays;
35+
import java.util.HashMap;
3636
import java.util.Map;
3737
import java.util.function.Predicate;
3838

@@ -342,7 +342,7 @@ private int otherIndex(int i) {
342342
* @return the index/lookup of atoms to the index they appear
343343
*/
344344
private static Map<IAtom, Integer> indexAtoms(IAtomContainer container) {
345-
Map<IAtom, Integer> map = Maps.newHashMapWithExpectedSize(container.getAtomCount());
345+
Map<IAtom, Integer> map = new HashMap<>(2*container.getAtomCount());
346346
for (int i = 0; i < container.getAtomCount(); i++)
347347
map.put(container.getAtom(i), i);
348348
return map;

base/standard/src/main/java/org/openscience/cdk/aromaticity/AtomTypeModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
package org.openscience.cdk.aromaticity;
2626

2727
import com.google.common.collect.ImmutableMap;
28-
import com.google.common.collect.Maps;
2928
import org.openscience.cdk.CDKConstants;
3029
import org.openscience.cdk.config.AtomTypeFactory;
3130
import org.openscience.cdk.exception.NoSuchAtomTypeException;
@@ -36,6 +35,7 @@
3635
import org.openscience.cdk.ringsearch.RingSearch;
3736

3837
import java.util.Arrays;
38+
import java.util.HashMap;
3939
import java.util.Map;
4040
import java.util.Objects;
4141

@@ -86,7 +86,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
8686

8787
Arrays.fill(electrons, -1);
8888

89-
final Map<IAtom, Integer> indexMap = Maps.newHashMapWithExpectedSize(nAtoms);
89+
final Map<IAtom, Integer> indexMap = new HashMap<>(2*nAtoms);
9090

9191
for (int i = 0; i < nAtoms; i++) {
9292

base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424

2525
package org.openscience.cdk.aromaticity;
2626

27-
import com.google.common.collect.Maps;
2827
import org.openscience.cdk.interfaces.IAtom;
2928
import org.openscience.cdk.interfaces.IAtomContainer;
3029
import org.openscience.cdk.interfaces.IBond;
3130
import org.openscience.cdk.interfaces.IPseudoAtom;
3231
import org.openscience.cdk.ringsearch.RingSearch;
3332

3433
import java.util.Arrays;
34+
import java.util.HashMap;
3535
import java.util.Map;
3636
import java.util.Objects;
3737

@@ -93,7 +93,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
9393
Arrays.fill(exocyclicPiBond, -1);
9494

9595
// index atoms and set the degree to the number of implicit hydrogens
96-
Map<IAtom, Integer> atomIndex = Maps.newHashMapWithExpectedSize(n);
96+
Map<IAtom, Integer> atomIndex = new HashMap<>(2*n);
9797
for (int i = 0; i < n; i++) {
9898
IAtom a = container.getAtom(i);
9999
atomIndex.put(a, i);

base/standard/src/main/java/org/openscience/cdk/tools/manipulator/AtomContainerManipulator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
* */
2525
package org.openscience.cdk.tools.manipulator;
2626

27-
import com.google.common.collect.Maps;
2827
import org.openscience.cdk.CDKConstants;
2928
import org.openscience.cdk.atomtype.CDKAtomTypeMatcher;
3029
import org.openscience.cdk.config.Elements;
@@ -615,7 +614,7 @@ public static void convertImplicitToExplicitHydrogens(IAtomContainer atomContain
615614
List<IBond> newBonds = new ArrayList<IBond>();
616615

617616
// store a single explicit hydrogen of each original neighbor
618-
Map<IAtom, IAtom> hNeighbor = Maps.newHashMapWithExpectedSize(atomContainer.getAtomCount());
617+
Map<IAtom, IAtom> hNeighbor = new HashMap<>(2*atomContainer.getAtomCount());
619618

620619
for (IAtom atom : atomContainer.atoms()) {
621620
if (!"H".equals(atom.getSymbol())) {

legacy/src/main/java/org/openscience/cdk/isomorphism/SmartsStereoMatch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package org.openscience.cdk.isomorphism;
2626

27-
import com.google.common.collect.Maps;
2827
import org.openscience.cdk.interfaces.IAtom;
2928
import org.openscience.cdk.interfaces.IAtomContainer;
3029
import org.openscience.cdk.interfaces.IBond;
@@ -37,6 +36,7 @@
3736
import org.openscience.cdk.isomorphism.matchers.smarts.StereoBond;
3837

3938
import java.util.Arrays;
39+
import java.util.HashMap;
4040
import java.util.Map;
4141
import java.util.function.Predicate;
4242

@@ -320,7 +320,7 @@ private int otherIndex(int i) {
320320
* @return the index/lookup of atoms to the index they appear
321321
*/
322322
private static Map<IAtom, Integer> indexAtoms(IAtomContainer container) {
323-
Map<IAtom, Integer> map = Maps.newHashMapWithExpectedSize(container.getAtomCount());
323+
Map<IAtom, Integer> map = new HashMap<>(2*container.getAtomCount());
324324
for (int i = 0; i < container.getAtomCount(); i++)
325325
map.put(container.getAtom(i), i);
326326
return map;

storage/ctab/src/main/java/org/openscience/cdk/io/MDLValence.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@
3232

3333
package org.openscience.cdk.io;
3434

35-
import com.google.common.collect.Maps;
3635
import org.openscience.cdk.interfaces.IAtom;
3736
import org.openscience.cdk.interfaces.IAtomContainer;
3837
import org.openscience.cdk.interfaces.IBond;
3938

39+
import java.util.HashMap;
4040
import java.util.Map;
4141

4242
/**
@@ -63,7 +63,7 @@ static IAtomContainer apply(IAtomContainer container) {
6363

6464
int[] valences = new int[n];
6565

66-
Map<IAtom, Integer> atomToIndex = Maps.newHashMapWithExpectedSize(n);
66+
Map<IAtom, Integer> atomToIndex = new HashMap<>(2*n);
6767
for (IAtom atom : container.atoms())
6868
atomToIndex.put(atom, atomToIndex.size());
6969

storage/smiles/src/main/java/org/openscience/cdk/smiles/CDKToBeam.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
package org.openscience.cdk.smiles;
2626

27-
import com.google.common.collect.Maps;
2827

2928
import org.openscience.cdk.CDKConstants;
3029
import org.openscience.cdk.config.Isotopes;
@@ -50,6 +49,7 @@
5049
import uk.ac.ebi.beam.GraphBuilder;
5150

5251
import java.io.IOException;
52+
import java.util.HashMap;
5353
import java.util.Map;
5454
import java.util.Objects;
5555

@@ -132,7 +132,7 @@ static Graph toBeamGraph(IAtomContainer ac, int flavour) throws CDKException {
132132
int order = ac.getAtomCount();
133133

134134
GraphBuilder gb = GraphBuilder.create(order);
135-
Map<IAtom, Integer> indices = Maps.newHashMapWithExpectedSize(order);
135+
Map<IAtom, Integer> indices = new HashMap<>(2*order);
136136

137137
for (IAtom a : ac.atoms()) {
138138
indices.put(a, indices.size());

storage/smiles/src/main/java/org/openscience/cdk/smiles/SmilesParser.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package org.openscience.cdk.smiles;
2525

2626
import com.google.common.collect.HashMultimap;
27-
import com.google.common.collect.Maps;
2827
import com.google.common.collect.Multimap;
2928
import org.openscience.cdk.CDKConstants;
3029
import org.openscience.cdk.exception.InvalidSmilesException;
@@ -316,7 +315,7 @@ private void parseMolCXSMILES(String title, IAtomContainer mol) throws InvalidSm
316315
// set the correct title
317316
mol.setTitle(title.substring(pos));
318317

319-
final Map<IAtom, IAtomContainer> atomToMol = Maps.newHashMapWithExpectedSize(mol.getAtomCount());
318+
final Map<IAtom, IAtomContainer> atomToMol = new HashMap<>(2*mol.getAtomCount());
320319
final List<IAtom> atoms = new ArrayList<>(mol.getAtomCount());
321320

322321
for (IAtom atom : mol.atoms()) {

0 commit comments

Comments
 (0)