Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help
The ASP Free website provides in-depth information on the latest developer tools available from Microsoft. Our cadre of writers, highly experienced industry experts, reveals the best ways to use established technologies as well as new and emerging technologies. Our coverage of Microsoft's development and administration technologies is among the most respected in the IT industry today.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Intel® Graphics Performance Analyzers is a powerful tool suite for analyzing and optimizing your games, media, and graphics-intensive applications. Used by some of the best developers on the planet, Intel GPA lets you maximize your app’s performance.


Tutorials
| Forums

Download to Enter
| Contest Rules

DOWNLOAD INTEL® GPA FOR FREE

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 3rd, 2005, 09:42 PM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 1,405 tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 21 h 39 m 2 sec
Reputation Power: 1594
Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye Send a message via Google Talk to tvc3mye Send a message via Skype to tvc3mye
Facebook
Question Generic Java Type comparison algorithm

Hi, I have a few questions to pose here, hopefully someone with experience can give me some insights and answers to these questions:

1. I wonder if there's any generic way of performing a comparison between two java variables regardless of the data type being passed in (of course, both variables must have the same data type)?

2. Is it possible to convert whatever data type into bytes and then perform a comparison by using XOR ?

3. If it is possible to do so, will the process be slow? To me, performance (execution speed) is one issue in my mind now.

4. If the approach of converting values of all data types into bytes for comparison is possible, how about java object types? Can I use the same way to compare Java objects?
__________________
When the programming world turns decent, the real world will turn upside down.

Reply With Quote
  #2  
Old July 4th, 2005, 06:42 AM
valined's Avatar
valined valined is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Oct 2004
Location: Brussels
Posts: 1,001 valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level)valined User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 2 Weeks 3 Days 19 h 42 m 49 sec
Reputation Power: 838
Exclamation

Quote:
Originally Posted by tvc3mye
1. I wonder if there's any generic way of performing a comparison between two java variables regardless of the data type being passed in (of course, both variables must have the same data type)?

Depends what you mean by "generic". If you what to do it on Java 1.4, check the sources for java.util.Arrays.sort(..) methods to see how the comparison is done. On Java 1.5 you can use the feature called 'generics'.
Quote:
Originally Posted by tvc3mye
2. Is it possible to convert whatever data type into bytes and then perform a comparison by using XOR ?

Yes, but pointless (because an object variable is just a reference to the object; you'll end up comparing memory addresses) except for primitive types (where relational operators are more efficient anyway)
Quote:
Originally Posted by tvc3mye
3. If it is possible to do so, will the process be slow? To me, performance (execution speed) is one issue in my mind now.

See anwser 2.
Quote:
Originally Posted by tvc3mye
4. If the approach of converting values of all data types into bytes for comparison is possible, how about java object types? Can I use the same way to compare Java objects?

See again answer 2.

[IMO the only sensible approach of comparing to objects is making them implement java.lang.Comparable interface.]

Reply With Quote
  #3  
Old July 4th, 2005, 09:26 PM
tvc3mye's Avatar
tvc3mye tvc3mye is offline
Daniel Schildsky
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 1,405 tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level)tvc3mye User rank is General 9th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 1 Day 21 h 39 m 2 sec
Reputation Power: 1594
Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye Send a message via Google Talk to tvc3mye Send a message via Skype to tvc3mye
Facebook
Thanks.

Thanks for your opinion.....

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Generic Java Type comparison algorithm


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.

© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap