Is there an idiomatic way to take a Set<K> and a Function<K,V>, and get a Map<K,V> live view? (i.e. the Map is backed by the Set and Function combo, and if e.g. an element is added to the Set, then the corresponding entry also exists in the Map).
(see e.g. Collections2.filter for more discussion on live views)
What if a live view is ...
When the enhanced for loop (foreach loop) was added to Java, it was made to work with a target of either an array or Iterable.
for ( T item : /*T[] or Iterable<? extends T>*/ ) {
//use item
}
That works great for Collection classes that only implement one type of iteration, and thus have a single iterator() method.
But I find mys...
Guava libraries are powerful, but i don't have still in mind all possibilities of this library.
I found very interesting tuto like http://scaramoche.blogspot.com/search/label/guava
But i didn't find any refcardz ?
...
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
...
I'm thinking of asking my team, of mixed skill levels, to use Google Guava. Prior to Guava, I'd have used the Apache Collections (or its generified version).
Guava, as opposed to Apache Collections, seems to be stronger in some ways, but perhaps less easy to use for less experienced programmers. Here's one area where I think might exemp...
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...
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...
Does Googe Guava for Java have a Function inner class with a void return value, like C#'s action? I'm tired of making a bunch of Function<Float, Integer> with meaningless return values.
...
Please explain the use of the interface Supplier(in Guava) with a suitable example .
...
Hi
Could someone tell me what I need to do to enable Guava support in GWT.
I have downloaded Guava R07 and in there there are the following two files:
guava-r07.jar
guava-r07-gwt.jar
I have a few questions regarding this:
Where do these files go? I am guessing that the standard Jar is made available to my IDE for coding, and that...
I am using below code to get & process value from google HashMultimap
HashMultimap hmm = new HashMultimap();
HashMultimap hmm2 = new HashMultimap();
Element ele;
:
hmm2.put("name","Amit");
hmm.put("Amit",ele);
hmm.put("rohit",hmm2);
:
Iterator itr = hmm.keys().iterator();
String ky = (String) itr.nex...
How would one implement a distinct predicate for use with the Google Collections Collections2.filter method?
...
Following obviously works, but I do not like to wrap items in Tuple,
ImmutableMap<String, Function<Tuple2<Double>, Double>> op = new //
ImmutableMap.Builder<String, Function<Tuple2<Double>, Double>>()
.put("+", new Function<Tuple2<Double>, Double>() {
@Override public Double apply(Tuple2<Double> data)...
We have a slow backend server that is getting crushed by load and we'd like the middle-tier Scala server to only have one outstanding request to the backend for each unique lookup.
The backend server only stores immutable data, but upon the addition of new data, the middle-tier servers will request the newest data on behalf of the cli...