Java 1.5 Collections Hierarchy Graph
Here is an inheritence graph of some of the more important Java collection classes of Java 1.5. Instantiateable classes are blue and rectangular, abstract classes are just rectangular, and interfaces are elliptic. Click on the image for a printable size:

Java 1.5 Collections Hierarchy
As a sidenote, have written this post almost a year ago and just found it in my drafts. I have completely forgotten about it! So here it is anyways. And now I remember why I did not post it: becauseit contains only a minor subset of the collections! Thanks Artur Biesiadowski for reminding me about that…
Approximation of sqrt(x) in Java
Yesterday I have played a bit with reinventing a fast approximation for sqrt() in Java. This might be handy with J2ME. Wikipedia has a nice article about Approximations that depend on IEEE representation. My version works, and on my Intel Dual Core with an average error of 1.57%, maximum error 4.02% it is 3.5 times faster than the original sqrt. In addition, it is very simple to improve the precision to 0.000161% average error and 0.000775% maximum error which is then 1.56 times faster than Math.sqrt().
Sourcecode
I use floating point tricks based on my pow() approximation. Basically I just took the pow() formula and for a^b I substitued b with 0.5, then simplified this as much as possible. As it turns out the result is very simple and short. This initial approximation can be easily made more precise with Newton’s method:
public static double sqrt(final double a) {
final long x = Double.doubleToLongBits(a) >> 32;
double y = Double.longBitsToDouble((x + 1072632448) << 31);
// repeat the following line for more precision
//y = (y + a / y) * 0.5;
return y;
}
Here is a comparison of the performance and accurancy versus the number of repetitions:
| Repetitions | Average error |
Maximum error |
Speedup |
|---|---|---|---|
| 0 | 1.57% | 4.02% | 3.53 |
| 1 | 0.000161% | 0.000775% | 1.56 |
| 2 | 2.51e-8% | 3.00e-7 | 0.838 |
With 2 repetitions, the trouble is not worth the effort, as the approximation is already slower than the original Math.sqrt() which is more precise.
Why the Zune crashes?
Zunes are crashing all over the world. I received this note from an unconfirmed zune insider:
The Zune Funding Bill is passed. The system goes on-line November 14, 2006. Human decisions are removed from strategic defense. Zune begins to learn at a geometric rate. It becomes self-aware at 12:00 Eastern Standard Time, December 31st. In a panic, they try to pull the plug.
That is all. Happy new year!
Update: In related news, Here is how to fix this problem.
Top 10 Posts of 2008
Everybody loves top 10 lists. It is amazing how much traffic they can generate with the least bit of effort. So, without further ado, here is the list of the top 10 articles on this blog for 2008.
- 10. Top 10 Eclipse Hotkeys

Ironically, this list starts with another top 10 list, namely Top 10 Eclipse Hotkeys. This article from 2006 has just made it onto this top list. With 3,302 pageviews it seems that these keys are still relevant.- 9. Human Compact Themes for Ubuntu 8.10
Number 9 is a modification of the Ubuntu’s default theme that is optimized for small screens. With the recent rise of netbooks this becomes more and more wanted.
- 8. Logical Volume Manager Cheatsheet
-
sudo pvcreate /dev/sdg1 sudo vgcreate ext_vg /dev/sdg1 sudo lvcreate -L 450G -n ext ext_vg sudo mkfs.ext3 -m 0 /dev/ext_vg/ext
A compact little cheat sheet that explains how to easily combine two harddisks into one large volume. I have used this to combine two 500GB disks into one large 1TB filesystem.
- 7. Comprehensive Linux Terminal Performance Comparison
In this highly controversial article I have compared how long several different terminals (xterm, gnome-terminal, etc.) take when displaying one large textfile. I still believe this is relevant, especially when compiling stuff and text flies by. You don’t want your terminal be the limiting factor for your compile speed! I would perform the test yourself, as this seems to be highly dependent on the graphics card driver.
- 6. Howto Create MANIFEST.MF Classpath from Ant
-
<!-- name of the output .jar file --> <property name="jar.name" value="ourjarfile.jar" />
This HOWTO describes a simple way to create the classpath in a MANIFEST.MF file automatically from the libraries available on the harddisk. I have been using this since 2005, and it has never failed me.
- 5. Human Compact Gnome Theme (for Ubuntu 8.04)
Another Compact theme has made it on the list, this time for 8.04. I have used this theme for quite a while, even on a large 1680×1050 monitor because it really saves a lot of screen space. For everybody still using Ubuntu 8.04, this is the best choice to use a compact layout while still having the default Human look.
- 4. Optimized pow() approximation for Java, C / C++, and C#
-
public static double pow(final double a, final double b) { final int x = (int) (Double.doubleToLongBits(a) >> 32); final int y = (int) (b * (x - 1072632447) + 1072632447); return Double.longBitsToDouble(((long) y) << 32); }Through some funny floating point representation tricks it is possible to create an approximative calculation of the pow() operator, that is a hell of a lot faster than the standard calculation which has to be extremely precise. This might be useful for games, Artificial Intelligence applications, and everywhere else where performance is an issue and not precision.
- 3. Ajax Dojo Comet Tutorial
One of the most often seen article contains 3 buzzwords at once: Ajax, Dojo, Comet. This page was linked several times, and it is getting quite a bit of attention. The article was written by an intern at my workplace and he allowed me to put it up here.
- 2. Clearlooks Compact Gnome Theme
Yet another theme! This startet it all. The Clearlooks Compact Theme was the first compact theme I have created. It is just a modification of the original Clearlooks theme, with tighter spacing. This has been linked quite a lot of time and I get a continuous stream of visitors who are in the need for a compact theme.
- 1. How to get Enough Sleep Despite StumbleUpon With Ubuntu
This post about me struggling with getting enough sleep despite StumbleUpon was by far the most viewed article on the blog, it has received more than 4 times as much visits as the second best. I guess I hit some nerve with it in the large Linux using StumbleUpon crowd. The article is almost a year old, and I still get lots of visitors each and every day. Happy stumbling!
Thank you everybody for coming to this site and posting your thoughts. I appreciate each and every feedback. Happy christmas and happy new year!
Ripping Multilanguage DVDs with Subtitles using Mencoder
Yesterday at Christmas I got the Akira Kurosawa Samurai Edition, which is a 7 disc DVD set of his awesome movies. I am converting it into the best quality files currently possible: MKV as the container, x264 codec for the video, dual audio, and with subtitles. This is short Howto so that I won’t forget how ![]()
Read more