I have an array in Java. Each entry of array is a pair of numbers (x and y coordinates).
Technically, an example of my array is:
setOfPoints = {(1,2), (3,4), (5,6), (1,9), (7,4)}
How can I search that list and check whether (3,4) is part of that set?
Ideally, I would like to do a Java function isCoordinateInSet((3,4), setOfPoints). I would also like to avoid using for loops that could potentially increase the time of operation. I am thinking of using Java Maps fpr this task. What do you think?
I am not following the Java syntax above, but I described it as so, to better explain what I want to do.
I would appreciate your input.
Thank you.
1 Answer