Java Datastructures
Greetings,
I was working on an embedded Java version where the height of the complex structures included in the API was a vector or a queue. This usually meant writing structures from scratch when needed.
Now I'm back in the land of the living, I will have full access to the real version of java with all the bells and whistles. This, however, presents a new problem, the API is quite large.
I was wondering if anyone can tell me about the important data structures that have emerged over the past two years. I mean lists, maps, tree structures that can handle concurrency and structures.
From what I remember there was a concurrency library, however, some standard collection structures also implemented concurrency aspects.
source to share
Start with Java Collections Training
http://java.sun.com/docs/books/tutorial/collections/index.html
This will cover all the basics.
Then, when you're happy, look at the parallel trailing trail.
http://java.sun.com/docs/books/tutorial/essential/concurrency/collections.html
However, it would be nice to also look at the Concurrency package.
source to share
pre java 1.4 you had collections with a synchronized way of flow control and then from java 1.5 lots of parallel collections where they are added. Using the correct collection will benefit your application in both performance and less memory usage. eg.
Synchronized
- Vector
- HashMap
- HashSet
Parallel
- CopyOnwriteArrayList
- ConcurrentHashMap
- ConcurrentHashSet
- ArrayBlockingQueue, etc.
You can do any collection sync by saying
Collections.synchronizedCollection(c);
Again, unnecessary use of concurrent / synchronized will degrade the performance of your application.
links given by pjp gr8 http://java.sun.com/docs/books/tutorial/collections/index.html http://java.sun.com/docs/books/tutorial/essential/concurrency/collections.html
One of them with all these collections goes through various open source collections like
guava library from Google http://code.google.com/p/google-collections/
Commons Collections http://commons.apache.org/proper/commons-collections/
source to share