I have two classes inside a package. Both call a method from another class, one works perfectly fine and the other gives the error java.lang.ClassNotFoundException
and the error
java.lang.NoClassDefFoundError: com/google/common/base/Predicate
The class path should be the same for both as they are in he same package so I can't figure o...
How can I concat two linked lists in O(1) with Java via jdk1.6, google or apache commons collection or whatever? E.g. in the jdk there is only the addAll method which is O(n).
Another feature I miss is to concat two lists where each of them could be in inverse order. To illustrate this assume two lists a->b->c and e->f->g could merged ...
I read through the javadoc and couldn't find anything that resembles it.
...
For sake of abstraction, let's assume that I have a
Map<Double, Collection<Employee>>
where key is salary threshold. Or for people familiar with Google collections it would be as
Multimap
I want to do a database lookup for each Employee's salary and if it's less than the salary threshold remove the employee it from the collection. ...
I would like to know a few practical use-cases (if they are not related/tied to any programming language it will be better).I can associate Sets, Lists and Maps to practical use cases.
For example if you wanted a glossary of a book where terms that you want are listed alphabetically and a location/page number is the value, you would us...
I'm using google-collections and trying to find the first element that satisfies Predicate if not, return me 'null'.
Unfortunately, Iterables.find and Iterators.find throws NoSuchElementException when no element is found.
Now, I am forced to do
Object found = null;
if ( Iterators.any( newIterator(...) , my_predicate )
{
found = It...
How can you compile the code using javac in a terminal by using google-collections in CLASSPATH?
Example of code trying to compile using javac in a terminal (works in Eclipse)
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
public class Locate {
...
BiMap<MyFile, Integer> rankingToResult = Hash...
I am looking to find guava-libraries in maven repository. It looks like guava is adding more features to google-collections library.
...
Has anyone had any luck rolling a custom GWT jar for Google Collections / Guava? I've tried uncommenting the relevant ant tasks and running them, but I just get empty folders in the JAR. Can't seem to get the include rules right :-/
...
I was looking for a decent implementation of a generic lazy non-modifiable list implementation to wrap my search result entries. The unmodifiable part of the task is easy as it can be achieved by Collections.unmodifiableList() so I only need to sort out the the lazy part.
Surprisingly, google-collections doesn't have anything to offer; ...
Hi all, is there a method (maybe with Google Collections) to obtain the min value of a Map(Key, Double)
In traditional way, I would have to sort the map according to the values, and take the first/last one.
thanks
...
I need to define a weak reference Map, whose value is a Set. I use Google collections' MapMaker, like this:
Map<Class<? extends Object>, Set<Foo>> map = new MapMaker().weakKeys().weakValues().makeMap();
So, for Set<Foo>, can I use a normal HashSet? Or, do I have to create a weak HashSet, like this:
Collections.newSetFromMap(new WeakH...
I can't see any way to build a Predicate that uses parenthesis to control logical order. Is there one?
Say I want to do something like
Predicate <= mumble and (foo or baz)
A simple Predicates.and or a Predicates.or has no equivalent that says "foo or baz" and with mumble.
Is this possible?
...
Dear all,
I need a Concurrent Hash Map with Weak or Soft keys were the equality is equals and not ==.
For this kind of keys, google collection chooses == by default.
Is there a way to override this choice? How should I proceed?
Best regards,
Nicolas.
...
How to sort a map(?,B) on the values in Java with google collections ordering function, if B is a class, which has a field of type double, which should be used for ordering.
...
Hey everyone,
I have a java project that I'm working on which was working until a few days ago. I'm not sure what I did to my Eclipse set-up to hose it but now I'm getting a java.lang.ClassNotFoundException when I try to run some code that accesses the google finance api. I've built a small test application that uses the google finance ...
A Google Collections Multiset is a set of elements each of which has a count (i.e. may be present multiple times).
I can't tell you how many times I want to do the following
Make a histogram (exactly Multiset)
Get the top N elements by count from the histogram
Examples: top 10 URLs (by # times mentioned), top 10 tags (by # times app...
I would like to be able to retrieve from my com.google.collections.Multimap<A, B> a Collection<Entry<A, Collection<B>>> which I expected from the entries() method, but in fact it returns a Collection<Entry<A, B>>. Is there a method which does what I want?
Currently I'm iterating like this:
for (A key: mmap.keySet()) {
Collection<B...
I didn't find such a multimap construction... When i want to do this, I iterate over the map, and populate the multimap. Is there an other way ??
final Map<String, Collection<String>> map = ImmutableMap.<String, Collection<String>>of(
"1", Arrays.asList("a", "b", "c", "c"));
System.out.println(Multimaps.forMap(map));
final ...
I love Google Guava and use it a lot, but there is one method I always find me writing..
public static <T> T tryFind(Iterable<T> iterable, Predicate<T> predicate){
for(T t : iterable){
if(predicate.apply(t)){
return t;
}
}
return null;
}
To me this seems to be a very useful addition to...