Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in descriptor ... NeighborList.java ? #556

Open
Luckick opened this Issue Apr 8, 2019 · 4 comments

Comments

Projects
None yet
2 participants
@Luckick
Copy link

Luckick commented Apr 8, 2019

In cdk/descriptor/qsarmolecular/src/main/java/org/openscience/cdk/geometry/surface/NeighborList.java
Line 60:

if (this.boxes.containsKey(key)) {
                List arl = this.boxes.get(key);
                arl.add(i);
                this.boxes.put(key, arl);
            } else {
                this.boxes.put(key, new ArrayList());
            }

In this circumstance, not all atoms are put into the neighbor list.

Should this be revised to:

if (this.boxes.containsKey(key)) {
                List arl = this.boxes.get(key);
                arl.add(i);
                this.boxes.put(key, arl);
            } else {
            	ArrayList arl = new ArrayList();
            	arl.add(i);
                this.boxes.put(key, arl);
                // this.boxes.put(key, new ArrayList());
            }

?
Thanks.

@johnmay

This comment has been minimized.

Copy link
Member

johnmay commented Apr 8, 2019

Yes I think so, will have to look at what this descriptor is doing but the better way to write this doing 1/2 the work and in less lines...

List arl = this.boxes.get(key);
if (arl == null)
  this.boxes.put(arl, arl = new ArrayList<>());
arl.add(i);

Java 8 has computeIfAbsent which is the same but this is the way to do it in Java 7.

@johnmay

This comment has been minimized.

Copy link
Member

johnmay commented Apr 8, 2019

Fancy making the Patch/PR?

@Luckick

This comment has been minimized.

Copy link
Author

Luckick commented Apr 8, 2019

Fancy making the Patch/PR?

How can I contribute to it? Revise and Pull request?

@johnmay

This comment has been minimized.

Copy link
Member

johnmay commented Apr 8, 2019

Yes please, same way you did with the other one #533. I will get round to that this week, sorry for the delay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.