Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Beginning Java
Hi can anybody suggest
maha devan
Ranch Hand
Posts: 50
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi people
I am having many sets of values(X,Y Coordinate values)
10, 20
10,15
200,130
10,30
30,30
I need to compare all(sets) coordinate values and find the value which is smallest.
In this case Answer is 10,15.
Can anybody suggest an efficient logic
Thanks
WarnerJan Veldhuis
Greenhorn
Posts: 9
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You could play with the Comparable interface, and use that to let it sort...
For the sake of speed, I made public members
For total correctness you would have to override the equals() and the hashcode() methods...
public class Coordinate implements Comparable { public int x,y; public int compareTo(Object object) { Coordinate c = (Coordinate) object; if ( this.x == c.x && this.y == c.y) { return 0; //equal } else if ( this.x < c.x && this.y < c.y ) { return -1; //smaller } else { return 1; //bigger } } }
maha devan
Ranch Hand
Posts: 50
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi need some more clarification I have code Like this
class Mahesh
{
public Point Foo() // This function returns minimum coord as point object
{
Hashtable hashobj; //This contains the values as key value pairs
}
}
I need to implement this functionality inside this function where I have all datas in a Hashtable . How to use comparator over here
Thanks
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Android: set y-coordinate of textview dynamically
Need Suggestion for next Certification
Maze Solving
drawing lines
was 7 in eclipse
More...