Skip to content

Commit

Permalink
Replace Lists usage - diamond brackets (1.7+) make thinks more concis…
Browse files Browse the repository at this point in the history
…e than the old help function.
  • Loading branch information
johnmay authored and egonw committed Jan 1, 2022
1 parent 0457dea commit 90d3209
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.openscience.cdk.graph;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.BitSet;
Expand Down Expand Up @@ -89,7 +88,7 @@ final class JumboPathGraph extends PathGraph {
if (limit < 3 || limit > ord) throw new IllegalArgumentException("limit should be from 3 to |V|");

for (int v = 0; v < ord; v++)
graph[v] = Lists.newArrayList();
graph[v] = new ArrayList<>();

// construct the path-graph
for (int v = 0; v < ord; v++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
package org.openscience.cdk.graph;

import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -90,7 +89,7 @@ final class RegularPathGraph extends PathGraph {
if (ord >= 64) throw new IllegalArgumentException("graph has 64 or more atoms, use JumboPathGraph");

for (int v = 0; v < ord; v++)
graph[v] = Lists.newArrayList();
graph[v] = new ArrayList<>();

// construct the path-graph
for (int v = 0; v < ord; v++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
*/
package org.openscience.cdk.graph;

import com.google.common.collect.Lists;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.hasItems;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.sameInstance;
import static org.junit.Assert.assertFalse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
Expand Down Expand Up @@ -137,7 +137,7 @@ public void lengths_naphthalene() throws IOException {
@Test
public void cycles_naphthalene() throws IOException {
InitialCycles initial = new InitialCycles(naphthalene());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(2));
assertThat(cycles.get(0).path(), is(new int[]{5, 0, 1, 2, 3, 4, 5}));
assertThat(cycles.get(1).path(), is(new int[]{5, 4, 7, 8, 9, 6, 5}));
Expand All @@ -151,7 +151,7 @@ public void lengths_anthracene() throws IOException {
@Test
public void cycles_anthracene() throws IOException {
InitialCycles initial = new InitialCycles(anthracene());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(3));
assertThat(cycles.get(0).path(), is(new int[]{5, 0, 1, 2, 3, 4, 5}));
assertThat(cycles.get(1).path(), is(new int[]{9, 6, 5, 4, 7, 8, 9}));
Expand All @@ -166,7 +166,7 @@ public void lengths_bicyclo() throws IOException {
@Test
public void cycles_bicyclo() throws IOException {
InitialCycles initial = new InitialCycles(bicyclo());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(3));
assertThat(cycles.get(0).path(), is(new int[]{5, 0, 1, 2, 3, 4, 5}));
assertThat(cycles.get(1).path(), is(new int[]{5, 0, 1, 2, 7, 6, 5}));
Expand All @@ -186,7 +186,7 @@ public void lengths_cyclophane() throws IOException {
@Test
public void cycles_cyclophane() throws IOException {
InitialCycles initial = new InitialCycles(cyclophane_odd());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(2));
assertThat(cycles.get(0).path(), is(new int[]{3, 2, 1, 0, 5, 4, 3}));
assertThat(cycles.get(1).path(), is(new int[]{3, 2, 1, 0, 10, 9, 8, 7, 6, 3}));
Expand All @@ -195,30 +195,30 @@ public void cycles_cyclophane() throws IOException {
@Test
public void cycles_cyclophane_odd_limit_5() throws IOException {
InitialCycles initial = new InitialCycles(cyclophane_odd(), 5);
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(0));
}

@Test
public void cycles_cyclophane_odd_limit_6() throws IOException {
InitialCycles initial = new InitialCycles(cyclophane_odd(), 6);
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(1));
assertThat(cycles.get(0).path(), is(new int[]{3, 2, 1, 0, 5, 4, 3}));
}

@Test
public void cycles_cyclophane_odd_limit_7() throws IOException {
InitialCycles initial = new InitialCycles(cyclophane_odd(), 7);
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.size(), is(1));
assertThat(cycles.get(0).path(), is(new int[]{3, 2, 1, 0, 5, 4, 3}));
}

@Test
public void cycles_family_odd() {
InitialCycles initial = new InitialCycles(cyclophane_odd());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.get(1).path(), is(new int[]{3, 2, 1, 0, 10, 9, 8, 7, 6, 3}));
int[][] family = cycles.get(1).family();
assertThat(family.length, is(2));
Expand All @@ -229,7 +229,7 @@ public void cycles_family_odd() {
@Test
public void cycles_family_even() {
InitialCycles initial = new InitialCycles(cyclophane_even());
List<InitialCycles.Cycle> cycles = Lists.newArrayList(initial.cycles());
List<InitialCycles.Cycle> cycles = new ArrayList<>(initial.cycles());
assertThat(cycles.get(1).path(), is(new int[]{3, 6, 7, 8, 9, 10, 11, 0, 1, 2, 3}));
int[][] family = cycles.get(1).family();
assertThat(family.length, is(2));
Expand Down

0 comments on commit 90d3209

Please sign in to comment.