google-collections

Is there a generic equivalent to ArrayIterator from Apache Commons Collections?

ArrayIterator is handy (although I don't need the reset functionality), but like the rest of the Commons Collections stuff, it doesn't use generics. I checked Google Collections, but I didn't see a close equivalent. Did I miss it? Is there another library of similar reputation and quality as the first two that provides such a thing? Than...

how to delete elements from a transformed collection using a predicate?

If I have an ArrayList<Double> dblList and a Predicate<Double> IS_EVEN I am able to remov e all even elements from dblList using: Collections2.filter(dblList, IS_EVEN).clear() if dblList however is a result of a transformation like dblList = Lists.transform(intList, TO_DOUBLE) this does not work any more as the transformed list is...

Atomically incrementing counters stored in ConcurrentHashMap

I would like to collect some metrics from various places in a web app. To keep it simple, all these will be counters and therefore the only modifier operation is to increment them by 1. The increments will be concurrent and often. The reads (dumping the stats) is a rare operation. I was thinking to use a ConcurrentHashMap. The issue i...

IllegalAnnotationsException SetMultimap is an interface, and JAXB can't handle interfaces

I have the following code: private SetMultimap<String, Dynamic> dynamicFields = TreeMultimap.create(Ordering.natural(), new Comparator<Dynamic>() { @Override public int compare(Dynamic o1, Dynamic o2) { return o1.getTitle().compareTo(o2.getTitle()); } }); which gives me the following exception. IllegalAnnotationsException S...

guava-libraries - Is the Ordering class thread safe?

The guava-libraries have a class Ordering. I'm wondering if it's thread safe. For example, can it be used as a static variable? public static Ordering<String> BY_LENGTH_ORDERING = new Ordering<String>() { public int compare(String left, String right) { return Ints.compare(left.length(), right.length()); } }; ...

Scala equivalent of Google Collections Lists.partition

I am looking for a function that will partition a list into fixed size sublists, exactly what Lists.partition from Google Collections library does. I couldn't find such method in the Scala Collections API. Am I missing something? ...

Can someone explain to me when it is useful to use MapMaker or WeakHashMaps?

Hi. I have read many people really like the MapMaker of Google Guava (Collections), however I cannot see any good uses of it. I have read the javadoc, and it says that it behaves like ConcurrentHashMap. It also says new MapMaker().weakKeys().makeMap() can almost always be used as a drop-in replacement for WeakHashMap. However, reading...

Google collections presentation slides on the web ?

Are the slides of the presentation linked from the Google collections page available somewhere as pdf or so on the web ? I.e. I'm looking for the slides of the overview video as it is easier to search e.g. a pdf than a video... I know that Google collections is now part of Guava Libraries but the 'PDF Slides of a recent presentation' ar...

Use of Google-collections MapMaker ?

I just came across this answer in SO where it is mentioned that the Google-collections MapMaker is awesome.I went through the documentation but couldn't really figure out where i can use it.Can any one point out some scenario's where it would be appropriate to use a MapMaker. ...

Java time-based map with expiring keys

Do any of you know of a Java Map or similar standard data store that automatically purges entries after a given timeout? Preferably in an open source library that is accessible via maven? I know of ways to implement the functionality myself and have done it several times in the past, so I'm not asking for advice in that respect, but for...

Google Collections ImmutableMap iteration order

I need combination of Google Collection ImmutableMap and LinkedHashMap immutable map with defined iteration order. It seems that ImmutableMap itself actually has defined iteration order, at least its documentation says: An immutable, hash-based Map with reliable user-specified iteration order. However there are no more details. Q...

How to iterate through google multimap

I have to iterate through google multimap. But I am using jdk 1.4 and can't switch to higher version. So i can not use generic features. My multimap can have multiple values for a key. There might be a situation when a value of multimap is multimap in itself ...

Priority Queue using MultiMap - Java

Hi. I have to implement Priority Queue using MultiMap. I use MultiMap from Google Collections. The following code creates a MultiMap and adds few elements into it. Multimap<Integer, String> multimap = HashMultimap.create(); multimap.put(5,"example"); multimap.put(1,"is"); multimap.put(1,"this"); multimap.put(4,"so...

HashMap alternatives for memory-efficient data storage

I've currently got a spreadsheet type program that keeps its data in an ArrayList of HashMaps. You'll no doubt be shocked when I tell you that this hasn't proven ideal. The overhead seems to use 5x more memory than the data itself. This question asks about efficient collections libraries, and the answer was use Google Collections. My...

Google Collections Distinct Predicate

How would one implement a distinct predicate for use with the Google Collections Collections2.filter method? ...