Skip to content
Permalink
Browse files
Use wildcards with Java types
  • Loading branch information
singhbaljit committed Dec 28, 2020
1 parent aabebd6 commit f850bcbfcc5dbfecf08b5a5091ff82fb3cc96eb1
Showing 32 changed files with 60 additions and 60 deletions.
@@ -238,7 +238,7 @@ protected <R extends AbstractConvexHyperplaneBoundedRegion<P, S>> Split<R> split
* @return the result of the split operation
*/
private <R extends AbstractConvexHyperplaneBoundedRegion<P, S>> Split<R> splitInternalFull(
final Hyperplane<P> splitter, final Class<S> boundaryType, final Function<List<S>, R> factory) {
final Hyperplane<P> splitter, final Class<S> boundaryType, final Function<? super List<S>, R> factory) {

final R minus = factory.apply(Collections.singletonList(boundaryType.cast(splitter.span())));
final R plus = factory.apply(Collections.singletonList(boundaryType.cast(splitter.reverse().span())));
@@ -257,7 +257,7 @@ private <R extends AbstractConvexHyperplaneBoundedRegion<P, S>> Split<R> splitIn
*/
private <R extends AbstractConvexHyperplaneBoundedRegion<P, S>> Split<R> splitInternalNonFull(
final Hyperplane<P> splitter, final R thisInstance, final Class<S> boundaryType,
final Function<List<S>, R> factory) {
final Function<? super List<S>, R> factory) {

final HyperplaneConvexSubset<P> trimmedSplitter = trim(splitter.span());

@@ -744,8 +744,8 @@ private RegionCutBoundary<P> computeBoundary() {
* of the region; may be null
*/
private void characterizeHyperplaneSubset(final HyperplaneConvexSubset<P> sub,
final AbstractRegionNode<P, N> node, final List<HyperplaneConvexSubset<P>> in,
final List<HyperplaneConvexSubset<P>> out) {
final AbstractRegionNode<P, N> node, final List<? super HyperplaneConvexSubset<P>> in,
final List<? super HyperplaneConvexSubset<P>> out) {

if (sub != null) {
if (node.isLeaf()) {
@@ -1104,14 +1104,14 @@ private RegionLocation condenseRecursive(final N node) {
extends IteratorTransform<N, C> {

/** Function that converts from the convex subset type to the output type. */
private final Function<HyperplaneConvexSubset<P>, C> typeConverter;
private final Function<? super HyperplaneConvexSubset<P>, C> typeConverter;

/** Simple constructor.
* @param inputIterator iterator that will provide all nodes in the tree
* @param typeConverter function that converts from the convex subset type to the output type
*/
RegionBoundaryIterator(final Iterator<N> inputIterator,
final Function<HyperplaneConvexSubset<P>, C> typeConverter) {
final Function<? super HyperplaneConvexSubset<P>, C> typeConverter) {
super(inputIterator);

this.typeConverter = typeConverter;
@@ -88,7 +88,7 @@ public double getSize() {
* @param boundaries boundaries to compute the size for
* @return the total size of all boundaries in the given list
*/
private double getTotalSize(final List<HyperplaneConvexSubset<P>> boundaries) {
private double getTotalSize(final List<? extends HyperplaneConvexSubset<P>> boundaries) {
double total = 0.0;
for (final HyperplaneConvexSubset<P> boundary : boundaries) {
total += boundary.getSize();
@@ -170,7 +170,7 @@ public boolean containsOutsideFacing(final P pt) {
* @param boundaries
* @return true if the point is contained in any of the given boundaries
*/
private boolean anyContains(final P pt, final List<HyperplaneConvexSubset<P>> boundaries) {
private boolean anyContains(final P pt, final List<? extends HyperplaneConvexSubset<P>> boundaries) {
for (final HyperplaneConvexSubset<P> boundary : boundaries) {
if (boundary.contains(pt)) {
return true;
@@ -175,7 +175,7 @@ private void checkInPlace(final Consumer<TestRegionBSPTree> assertions) {
}

private void checkInternal(final boolean inPlace, final Operation operation,
final Consumer<TestRegionBSPTree> assertions) {
final Consumer<? super TestRegionBSPTree> assertions) {

final TestRegionBSPTree tree1 = tree1Factory.get();
final TestRegionBSPTree tree2 = tree2Factory.get();
@@ -371,7 +371,7 @@ public Interval getNodeRegion() {
* @param visitor the object that will receive the min and max boundaries for the node's
* convex region
*/
private void visitNodeInterval(final BiConsumer<OrientedPoint, OrientedPoint> visitor) {
private void visitNodeInterval(final BiConsumer<? super OrientedPoint, ? super OrientedPoint> visitor) {
OrientedPoint min = null;
OrientedPoint max = null;

@@ -402,7 +402,7 @@ public Split<PlaneConvexSubset> split(final Hyperplane<Vector3D> splitter) {
* @return the list of vertices for the split result
*/
private List<Vector3D> buildPolygonSplitVertexList(final int enterIdx, final Vector3D newEnterPt,
final int exitIdx, final Vector3D newExitPt, final List<Vector3D> vertices) {
final int exitIdx, final Vector3D newExitPt, final List<? extends Vector3D> vertices) {

final int size = vertices.size();

@@ -176,7 +176,7 @@ public static ConvexVolume fromBounds(final Plane... planes) {
* @throws IllegalArgumentException if the given set of bounding planes do not form a convex volume,
* meaning that there is no region that is on the minus side of all of the bounding planes.
*/
public static ConvexVolume fromBounds(final Iterable<Plane> boundingPlanes) {
public static ConvexVolume fromBounds(final Iterable<? extends Plane> boundingPlanes) {
final List<PlaneConvexSubset> facets = new ConvexRegionBoundaryBuilder<>(PlaneConvexSubset.class)
.build(boundingPlanes);
return facets.isEmpty() ? full() : new ConvexVolume(facets);
@@ -234,7 +234,7 @@ public static List<Triangle3D> indexedTriangles(final Vector3D[] vertices, final
* @throws IndexOutOfBoundsException if any index into {@code vertices} is out of bounds
* @see #indexedTriangles(Vector3D[], int[][], DoublePrecisionContext)
*/
public static List<Triangle3D> indexedTriangles(final List<Vector3D> vertices, final int[][] faceIndices,
public static List<Triangle3D> indexedTriangles(final List<? extends Vector3D> vertices, final int[][] faceIndices,
final DoublePrecisionContext precision) {

final int numFaces = faceIndices.length;
@@ -313,7 +313,7 @@ public static List<ConvexPolygon3D> indexedConvexPolygons(final Vector3D[] verti
* @throws IndexOutOfBoundsException if any index into {@code vertices} is out of bounds
* @see #indexedConvexPolygons(Vector3D[], int[][], DoublePrecisionContext)
*/
public static List<ConvexPolygon3D> indexedConvexPolygons(final List<Vector3D> vertices, final int[][] faceIndices,
public static List<ConvexPolygon3D> indexedConvexPolygons(final List<? extends Vector3D> vertices, final int[][] faceIndices,
final DoublePrecisionContext precision) {
final int numFaces = faceIndices.length;
final List<ConvexPolygon3D> polygons = new ArrayList<>(numFaces);
@@ -446,7 +446,7 @@ static void validatePlanesEquivalent(final Plane expected, final Plane actual) {
* @return the result of the split operation
*/
static <T extends PlaneSubset> Split<T> subspaceSplit(final Plane splitter, final T subset,
final BiFunction<EmbeddingPlane, HyperplaneBoundedRegion<Vector2D>, T> factory) {
final BiFunction<? super EmbeddingPlane, ? super HyperplaneBoundedRegion<Vector2D>, T> factory) {

final EmbeddingPlane thisPlane = subset.getPlane().getEmbedding();

@@ -610,7 +610,7 @@ private static int findBestTriangleFanIndex(final List<Vector3D> vertices) {
private static final class PlaneBuilder {

/** The point sequence to build a plane for. */
private final Collection<Vector3D> pts;
private final Collection<? extends Vector3D> pts;

/** Precision context used for floating point comparisons. */
private final DoublePrecisionContext precision;
@@ -640,13 +640,13 @@ private static final class PlaneBuilder {
private boolean requireConvex = false;

/** List that unique vertices discovered in the input sequence will be added to. */
private List<Vector3D> uniqueVertexOutput;
private List<? super Vector3D> uniqueVertexOutput;

/** Construct a new build instance for the given point sequence and precision context.
* @param pts point sequence
* @param precision precision context used to perform floating point comparisons
*/
PlaneBuilder(final Collection<Vector3D> pts, final DoublePrecisionContext precision) {
PlaneBuilder(final Collection<? extends Vector3D> pts, final DoublePrecisionContext precision) {
this.pts = pts;
this.precision = precision;
}
@@ -672,7 +672,7 @@ Plane build() {
* @throws IllegalArgumentException if the points do not define a plane or the {@code requireConvex}
* flag is true and the points do not define a convex area
*/
Plane buildForConvexPolygon(final List<Vector3D> vertexOutput) {
Plane buildForConvexPolygon(final List<? super Vector3D> vertexOutput) {
this.requireConvex = true;
this.uniqueVertexOutput = vertexOutput;

@@ -840,7 +840,7 @@ public List<PlaneConvexSubset> extrude(final RegionBSPTree2D subspaceRegion) {
* @param subspaceRegion subspace region being extruded.
* @param result list to add the boundary results to
*/
private void addEnds(final RegionBSPTree2D subspaceRegion, final List<PlaneConvexSubset> result) {
private void addEnds(final RegionBSPTree2D subspaceRegion, final List<? super PlaneConvexSubset> result) {
// add the base boundaries
final List<ConvexArea> baseAreas = subspaceRegion.toConvex();

@@ -868,7 +868,7 @@ private void addEnds(final RegionBSPTree2D subspaceRegion, final List<PlaneConve
* @param subspaceRegion subspace region being extruded.
* @param result list to add the boundary results to
*/
private void addSides(final RegionBSPTree2D subspaceRegion, final List<PlaneConvexSubset> result) {
private void addSides(final RegionBSPTree2D subspaceRegion, final List<? super PlaneConvexSubset> result) {
Vector2D subStartPt;
Vector2D subEndPt;

@@ -106,7 +106,7 @@ public List<ConvexVolume> toConvex() {
* @param result list containing the results of the computation
*/
private void toConvexRecursive(final RegionNode3D node, final ConvexVolume nodeVolume,
final List<ConvexVolume> result) {
final List<? super ConvexVolume> result) {

if (node.isLeaf()) {
// base case; only add to the result list if the node is inside
@@ -544,7 +544,7 @@ public static Vector3D max(final Iterable<Vector3D> vecs) {
* @param more iterator with additional vectors
* @return vector containing the maximum component values of all input vectors
*/
private static Vector3D computeMax(final Vector3D first, final Iterator<Vector3D> more) {
private static Vector3D computeMax(final Vector3D first, final Iterator<? extends Vector3D> more) {
double x = first.getX();
double y = first.getY();
double z = first.getZ();
@@ -589,7 +589,7 @@ public static Vector3D min(final Iterable<Vector3D> vecs) {
* @param more iterator with additional vectors
* @return vector containing the minimum component values of all input vectors
*/
private static Vector3D computeMin(final Vector3D first, final Iterator<Vector3D> more) {
private static Vector3D computeMin(final Vector3D first, final Iterator<? extends Vector3D> more) {
double x = first.getX();
double y = first.getY();
double z = first.getZ();
@@ -636,7 +636,7 @@ public static Vector3D centroid(final Iterable<Vector3D> pts) {
* @param more iterator with additional points
* @return the centroid of the point set
*/
private static Vector3D computeCentroid(final Vector3D first, final Iterator<Vector3D> more) {
private static Vector3D computeCentroid(final Vector3D first, final Iterator<? extends Vector3D> more) {
double x = first.getX();
double y = first.getY();
double z = first.getZ();
@@ -102,7 +102,7 @@ public static void sortAndFilter(final List<LinecastPoint3D> pts) {
* @param list list to test against
* @return true if the given linecast point is equivalent to any of those in the given list
*/
private static boolean containsEq(final LinecastPoint3D pt, final List<LinecastPoint3D> list) {
private static boolean containsEq(final LinecastPoint3D pt, final List<? extends LinecastPoint3D> list) {
final DoublePrecisionContext precision = pt.getLine().getPrecision();

for (final LinecastPoint3D listPt : list) {
@@ -380,13 +380,13 @@ public String toString() {
private int index = 0;

/** Function to apply to each face in the mesh. */
private final Function<TriangleMesh.Face, T> fn;
private final Function<? super TriangleMesh.Face, T> fn;

/** Construct a new instance for iterating through the mesh faces and extracting
* a value from each.
* @param fn function to apply to each face in order to obtain the iterated value
*/
FaceIterator(final Function<TriangleMesh.Face, T> fn) {
FaceIterator(final Function<? super TriangleMesh.Face, T> fn) {
this.fn = fn;
}

@@ -495,7 +495,7 @@ public Builder addVertices(final Vector3D[] newVertices) {
* @return this instance
* @see #addVertex(Vector3D)
*/
public Builder addVertices(final Collection<Vector3D> newVertices) {
public Builder addVertices(final Collection<? extends Vector3D> newVertices) {
final int newSize = vertices.size() + newVertices.size();
ensureVertexCapacity(newSize);

@@ -672,7 +672,7 @@ private Map<Vector3D, Integer> getVertexIndexMap() {
* @param map vertex index map
* @return the index now associated with the given vertex or its equivalent
*/
private int addToVertexIndexMap(final Vector3D vertex, final int targetIdx, final Map<Vector3D, Integer> map) {
private int addToVertexIndexMap(final Vector3D vertex, final int targetIdx, final Map<? super Vector3D, Integer> map) {
validateCanModify();

final Integer actualIdx = map.putIfAbsent(vertex, targetIdx);
@@ -189,7 +189,7 @@ public static Builder builder(final DoublePrecisionContext precision) {
* @return a parallelepiped face created from the indexed vertices
*/
private static PlaneConvexSubset createFace(final int a, final int b, final int c, final int d,
final List<Vector3D> vertices, final boolean reverse, final DoublePrecisionContext precision) {
final List<? extends Vector3D> vertices, final boolean reverse, final DoublePrecisionContext precision) {

final Vector3D pa = vertices.get(a);
final Vector3D pb = vertices.get(b);
@@ -216,7 +216,7 @@ public Builder add(final Vector2D pt) {
* @param pts points to add
* @return this instance
*/
public Builder addAll(final Iterable<Vector2D> pts) {
public Builder addAll(final Iterable<? extends Vector2D> pts) {
for (final Vector2D pt : pts) {
add(pt);
}
@@ -100,7 +100,7 @@ public static void sortAndFilter(final List<LinecastPoint2D> pts) {
* @param list list to test against
* @return true if the given linecast point is equivalent to any of those in the given list
*/
private static boolean containsEq(final LinecastPoint2D pt, final List<LinecastPoint2D> list) {
private static boolean containsEq(final LinecastPoint2D pt, final List<? extends LinecastPoint2D> list) {
final DoublePrecisionContext precision = pt.getLine().getPrecision();

for (final LinecastPoint2D listPt : list) {
@@ -128,7 +128,7 @@ public List<ConvexArea> toConvex() {
* form the convex areas for any child nodes
* @param result list containing the results of the computation
*/
private void toConvexRecursive(final RegionNode2D node, final ConvexArea nodeArea, final List<ConvexArea> result) {
private void toConvexRecursive(final RegionNode2D node, final ConvexArea nodeArea, final List<? super ConvexArea> result) {
if (node.isLeaf()) {
// base case; only add to the result list if the node is inside
if (node.isInside()) {
@@ -483,7 +483,7 @@ public static Vector2D max(final Iterable<Vector2D> vecs) {
* @param more iterator with additional vectors
* @return vector containing the maximum component values of all input vectors
*/
private static Vector2D computeMax(final Vector2D first, final Iterator<Vector2D> more) {
private static Vector2D computeMax(final Vector2D first, final Iterator<? extends Vector2D> more) {
double x = first.getX();
double y = first.getY();

@@ -526,7 +526,7 @@ public static Vector2D min(final Iterable<Vector2D> vecs) {
* @param more iterator with additional vectors
* @return vector containing the minimum component values of all input vectors
*/
private static Vector2D computeMin(final Vector2D first, final Iterator<Vector2D> more) {
private static Vector2D computeMin(final Vector2D first, final Iterator<? extends Vector2D> more) {
double x = first.getX();
double y = first.getY();

@@ -571,7 +571,7 @@ public static Vector2D centroid(final Iterable<Vector2D> pts) {
* @param more iterator with additional points
* @return the centroid of the point set
*/
private static Vector2D computeCentroid(final Vector2D first, final Iterator<Vector2D> more) {
private static Vector2D computeCentroid(final Vector2D first, final Iterator<? extends Vector2D> more) {
double x = first.getX();
double y = first.getY();

@@ -48,7 +48,7 @@ public void add(final LineConvexSubset subset) {
* @see #connectAll()
* @see #add(LineConvexSubset)
*/
public void add(final Iterable<LineConvexSubset> subsets) {
public void add(final Iterable<? extends LineConvexSubset> subsets) {
for (final LineConvexSubset subset : subsets) {
add(subset);
}
@@ -64,7 +64,7 @@ public void add(final Iterable<LineConvexSubset> subsets) {
* @param subsets line subsets to connect
* @see #connectAll()
*/
public void connect(final Iterable<LineConvexSubset> subsets) {
public void connect(final Iterable<? extends LineConvexSubset> subsets) {
final List<ConnectableLineSubset> newEntries = new ArrayList<>();

for (final LineConvexSubset subset : subsets) {

0 comments on commit f850bcb

Please sign in to comment.