diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java index a8f250fba2..4a84ef6543 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose2d.java @@ -20,9 +20,9 @@ import edu.wpi.first.math.numbers.N3; import edu.wpi.first.units.measure.Distance; import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.List; import java.util.Objects; /** Represents a 2D pose containing translational and rotational elements. */ @@ -347,13 +347,13 @@ public class Pose2d implements Interpolatable, ProtobufSerializable, Str } /** - * Returns the nearest Pose2d from a list of poses. If two or more poses in the list have the same - * distance from this pose, return the one with the closest rotation component. + * Returns the nearest Pose2d from a collection of poses. If two or more poses in the collection + * have the same distance from this pose, return the one with the closest rotation component. * - * @param poses The list of poses to find the nearest. - * @return The nearest Pose2d from the list. + * @param poses The collection of poses to find the nearest. + * @return The nearest Pose2d from the collection. */ - public Pose2d nearest(List poses) { + public Pose2d nearest(Collection poses) { return Collections.min( poses, Comparator.comparing( diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java index f08618b566..20204235bc 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Pose3d.java @@ -21,9 +21,9 @@ import edu.wpi.first.math.numbers.N4; import edu.wpi.first.units.measure.Distance; import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.List; import java.util.Objects; /** Represents a 3D pose containing translational and rotational elements. */ @@ -400,13 +400,13 @@ public class Pose3d implements Interpolatable, ProtobufSerializable, Str } /** - * Returns the nearest Pose3d from a list of poses. If two or more poses in the list have the same - * distance from this pose, return the one with the closest rotation component. + * Returns the nearest Pose3d from a collection of poses. If two or more poses in the collection + * have the same distance from this pose, return the one with the closest rotation component. * - * @param poses The list of poses to find the nearest. - * @return The nearest Pose3d from the list. + * @param poses The collection of poses to find the nearest. + * @return The nearest Pose3d from the collection. */ - public Pose3d nearest(List poses) { + public Pose3d nearest(Collection poses) { return Collections.min( poses, Comparator.comparing( diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java index 9b4af815c7..1612a5e5fa 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation2d.java @@ -20,9 +20,9 @@ import edu.wpi.first.math.numbers.N2; import edu.wpi.first.units.measure.Distance; import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.List; import java.util.Objects; /** @@ -273,12 +273,12 @@ public class Translation2d } /** - * Returns the nearest Translation2d from a list of translations. + * Returns the nearest Translation2d from a collection of translations. * - * @param translations The list of translations. - * @return The nearest Translation2d from the list. + * @param translations The collection of translations. + * @return The nearest Translation2d from the collection. */ - public Translation2d nearest(List translations) { + public Translation2d nearest(Collection translations) { return Collections.min(translations, Comparator.comparing(this::getDistance)); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java index 1aad1a892b..a929661ee9 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java +++ b/wpimath/src/main/java/edu/wpi/first/math/geometry/Translation3d.java @@ -20,9 +20,9 @@ import edu.wpi.first.math.numbers.N3; import edu.wpi.first.units.measure.Distance; import edu.wpi.first.util.protobuf.ProtobufSerializable; import edu.wpi.first.util.struct.StructSerializable; +import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.List; import java.util.Objects; /** @@ -305,7 +305,7 @@ public class Translation3d * @param translations The collection of translations to find the nearest. * @return The nearest Translation3d from the collection. */ - public Translation3d nearest(List translations) { + public Translation3d nearest(Collection translations) { return Collections.min(translations, Comparator.comparing(this::getDistance)); }