Java 11 migrate all remaining s (#1120)

* Moves saga to Java 11

* Moves semaphore to Java 11

* Moves servant to Java 11

* Moves serverless to Java 11

* Moves service-layer to Java 11

* Moves service-locator to Java 11

* Moves sharding to Java 11

* Moves singleton to Java 11

* Moves spatial-partition to Java 11

* Moves specification to Java 11

* Moves state to Java 11

* Moves step-builder to Java 11

* Moves strategy to Java 11

* Moves subclass-sandbox to Java 11

* Fixes checkstyle issues
This commit is contained in:
Anurag Agarwal
2020-01-04 22:06:08 +05:30
committed by Ilkka Seppälä
parent 310ae50248
commit cd2a2e7711
98 changed files with 718 additions and 855 deletions
@@ -23,8 +23,7 @@
package com.iluwatar.spatialpartition;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Collection;
import java.util.Hashtable;
/**
@@ -47,7 +46,7 @@ public class QuadTree {
this.boundary = boundary;
this.capacity = capacity;
this.divided = false;
this.points = new Hashtable<Integer, Point>();
this.points = new Hashtable<>();
this.northwest = null;
this.northeast = null;
this.southwest = null;
@@ -76,30 +75,29 @@ public class QuadTree {
}
void divide() {
double x = this.boundary.coordinateX;
double y = this.boundary.coordinateY;
double width = this.boundary.width;
double height = this.boundary.height;
Rect nw = new Rect(x - width / 4, y + height / 4, width / 2, height / 2);
var x = this.boundary.coordinateX;
var y = this.boundary.coordinateY;
var width = this.boundary.width;
var height = this.boundary.height;
var nw = new Rect(x - width / 4, y + height / 4, width / 2, height / 2);
this.northwest = new QuadTree(nw, this.capacity);
Rect ne = new Rect(x + width / 4, y + height / 4, width / 2, height / 2);
var ne = new Rect(x + width / 4, y + height / 4, width / 2, height / 2);
this.northeast = new QuadTree(ne, this.capacity);
Rect sw = new Rect(x - width / 4, y - height / 4, width / 2, height / 2);
var sw = new Rect(x - width / 4, y - height / 4, width / 2, height / 2);
this.southwest = new QuadTree(sw, this.capacity);
Rect se = new Rect(x + width / 4, y - height / 4, width / 2, height / 2);
var se = new Rect(x + width / 4, y - height / 4, width / 2, height / 2);
this.southeast = new QuadTree(se, this.capacity);
this.divided = true;
}
ArrayList<Point> query(Rect r, ArrayList<Point> relevantPoints) {
Collection<Point> query(Rect r, Collection<Point> relevantPoints) {
//could also be a circle instead of a rectangle
if (this.boundary.intersects(r)) {
for (Enumeration<Integer> e = this.points.keys(); e.hasMoreElements(); ) {
Integer i = e.nextElement();
if (r.contains(this.points.get(i))) {
relevantPoints.add(this.points.get(i));
}
}
this.points
.values()
.stream()
.filter(r::contains)
.forEach(relevantPoints::add);
if (this.divided) {
this.northwest.query(r, relevantPoints);
this.northeast.query(r, relevantPoints);