Forum Controls
Spotlight Features

The Rich Engineering Heritage Behind Dependency Injection

Andrew McVeigh takes us on a tour of the rich heritage behind dependency injection, what it represents, and tells us why its here to stay.

NetBeans 6: Matisse Updates

NetBeans 6 delivers great updates to the Matisse GUI builder. Spend a few minutes with Roman Strobl and get an expert briefing on what's new and what has changed.

Introduction to Groovy Part 3

In this, the third and final installation of Andres' Introduction to Groovy series, you learn about how Groovy handles variable numbers of arguments, named parameters, currying, and more about Groovy operators. Including, some new operators.

Easier Custom Components with Swing Fuse

Swing Fuse (actually just Fuse), is a framework designed to make it easier to create your own custom desktop components. In this article, Daniel Spiewak shows you how to get started and provides sample source code you can download.

Benchmark Analysis: Guice vs Spring

Willam Louth shows how he uses JXInsight Probes to investigate probable performance issues with code bases that he is not familiar with. He also highlights possible pitfalls in creating a benchmark, as well as in the analysis of results.
Replies: 21 - Pages: 2   [ 1 2 | Next ]
Threads: [ Previous | Next ]
  Click to reply to this thread Reply

What is the Google Collections Library?

URL: What is the Google Collections Library?

At 9:46 AM on Oct 24, 2007, Michael Urban wrote:

What is the Google Collections Library and how can you use it as a developer? The Google Collections Library is an exciting development in the Java world, and in in this article , Geertjan interviews Kevin Bourrillion and Jared Levy, the two primary creators of the Google Collections Library for the full story.

Read the full article now.
1 . At 10:29 AM on Oct 24, 2007, David Gilbert DeveloperZone Top 100 wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

Nice interview, thanks! It definitely sounds like an API worth looking into some more...even better if it can find its way into the JDK eventually.
Dave Gilbert
http://www.jfree.org
2 . At 1:16 PM on Oct 24, 2007, Mike P wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

Multimap<Salesperson, Sale> multimap = new ArrayListMultimap<Salesperson,Sale>();
 
public void makeSale(Salesperson salesPerson, Sale sale)
{
  multimap.put(salesperson, sale);
}

I have a slight issue with this.
'get' ought to return the same as you 'put' in.
What does get return? Not the 'sale', because it's a list of sales. So it probably returns the list.
Would it not have been better if multimap had an 'add' instead?
  multimap.add(salesperson, sale);
3 . At 3:15 PM on Oct 24, 2007, Hollis Waite wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

A generics-enabled version of Commons Collections does exist: www.sourceforge.net/projects/collections.
4 . At 3:41 PM on Oct 24, 2007, Nipsu wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

fastutil extends the Java? Collections Framework by providing type-specific maps, sets, lists and queues with a small memory footprint and fast access and insertion; it also includes a fast I/O API for binary and text files. It is free software distributed under the GNU Lesser General Public License.

http://fastutil.dsi.unimi.it/

I've been using fastutil for many years. The generics enabled version has been available for year and a half? (not sure) already.

Haven't done any bmarking recently but back then when I tested it it was *very* fast. It also offers maps (and sets) with different strategies: ArrayMap, AVLTreeMap, LinkedOpenHashMap, OpenHashMap, and RBTreeMap. Synchronized and unmodifiable versions can be constructed. etc..

Current version is 5.0.9.

P.S.
Primary motivation for my usage is that fastutil offers collections for different primitive types. I need to cache lots of data and the primitive versions are much, much more memory efficient (and faster) than the object based.
5 . At 4:18 PM on Oct 24, 2007, Mike P wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

At first glance fastutil's collections looks good.
Question:
IntArrays.
public static void fill(int[] array,
                        int from,
                        int to,
                        int value)

to - the end index of the portion to fill.
Is that inclusive or exclusive.
A lot of end-indexes in Sun's code are exclusive and I like it that way.

Also just noticed this:
ensureFromTo, Ensures that a range given by its first (inclusive) and last (exclusive) elements fits an array.
But then it states:
from - a start index (inclusive).
to - an end index (inclusive).
Is it inclusive or exclusive?

Shouldn't BooleanArraySet be BooleanHashSet ? And wouldn't it store only 2 possible values, false and true?

On the various iterators, do they support 'remove'?

Overal, looks pretty bella to me, very useful, thanks.
6 . At 4:38 PM on Oct 24, 2007, Kevin Bourrillion wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

Huh. I could *not* find that when I was looking for it, and Stephen never mentioned it to me either. All I had really found was a page describing how much a few people *wanted* this to happen, along with a plea that could someone out there please pitch in and do it?

In any case, it would be great to have a neutral third party compare and contrast the two libraries. They aren't just two implementations of the same thing; they each have their own approach and philosophy etc.
7 . At 4:39 PM on Oct 24, 2007, Mike P wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

MultiHashMap.getCollection - returns the collection mapped to the key, null if no mapping.

It would be a lot better if getCollection would return an immutable empty collection if not found, that way you can do the following without any null pointer exceptions:
for (String text : textMap.getCollection(entry))
{
}


In the various hash maps:
public V put(Object key, Object value)
Shouldn't that be:
public V put(K key, V value)
That way you have the compiler check things for you.

Looks like the javadocs point to jdk 1.3 for the base classes. It's K,V in java 1.5.


Frankly, I've avoided Apache libraries unless someone threw them in my face. I find a lot of what I've seen sloppy design work. Noble efforts, but not of Jedi caliper by any stretch.
8 . At 4:41 PM on Oct 24, 2007, Kevin Bourrillion wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

Multimap.put() is so named because the design philosophy of Multimap is to be "Just like a Map, but without the unique-keys restriction". Whether get(K) is the right name for the method that returns the collection-view of values associated with K could be debated. Perhaps values(K), but we can't wind up with an API that has no "get-" method or boy will people be confused.
9 . At 4:50 PM on Oct 24, 2007, Kevin Bourrillion wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

The comment about MultiHashMap is, I think, in reference to the Apache library? (I'm not really familiar beyond a superficial level with the Apache library, as reading it kind of feels like cheating or something.)

We definitely agree that asking for the values associated with a key that isn't present in the multimap should give you an empty collection. Our approach, though, is for that returned collection to be immutable only if your multimap to begin with was immutable. For a mutable multimap, the returned collection is a live, read-through, write-through view unto the multimap.

This view-based approach enables some truly powerful stuff. Every API that works on a mutable collection is available to you, so you can really accomplish a lot with only a little bit of code.
10 . At 4:51 PM on Oct 24, 2007, Kevin Bourrillion wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

"immutable if and only if the multimap itself was immutable" -- and as well, unmodifiable if and only if the multimap reference itself is unmodifiable.
11 . At 5:15 PM on Oct 24, 2007, Mike P wrote:
  Click to reply to this thread Reply

Re: What is the Google Collections Library?

How about:
V get(K);
V put(K, V);
Collection<V> values(K);
void add(K, V);


get returns the last item added or put, null if not found.

put replaces the content, returns the last previous item or not if not found.

values never returns null (empty collection if not found).
null.

add adds a value to the collection.


Consistent, clean, compatible with the base, behaving exactly the same. put *replaces*, and doesn't add.

I really don't like how put does an add behind the scenes in the current implementation.
12 . At 10:54 AM on Oct 25, 2007, Thomas R. Corbin wrote:
  Click to reply to this thread Reply

How does this complement glazedlists?

Glazedlists are my favorite library, though they are limited to lists, I think.

I'd love to see some blending between the two libraries.
13 . At 3:13 PM on Oct 25, 2007, Kevin Bourrillion wrote:
  Click to reply to this thread Reply

Re: How does this complement glazedlists?

> How does this complement glazedlists?
> Glazedlists are my favorite library, though they are
> limited to lists, I think.

Ha! It's funny you should ask, since coincidentally enough, a fair chunk of the development of the Google Collections took place about 3 meters away from Jesse, who was in the next office over from me. Jesse and I worked on AdWords together (and also work on regular guilty-pleasure Starbucks trips together).

Glazed Lists does stuff we don't do, and when people have suggested we do it, we say, "check out Glazed Lists".

I pinged Jesse to come answer this question in more detail cause he'd obviously have the most useful answer.


> I'd love to see some blending between the two
> libraries.

Good idea. Let's start by contacting this guy:

http://youtube.com/watch?v=8NeR2LyILWQ
14 . At 6:48 PM on Oct 25, 2007, Thomas R. Corbin wrote:
  Click to reply to this thread Reply

Re: How does this complement glazedlists?

Well, I'm hoping that the glazed lists stuff gets into the jdk. I think the PublicObject folks have said in the past that they'd like to get that done.

I absolutely love glazed lists, it does so much for me.

That blender guy is just too funny. He cracks me up.

thread.rss_message