I'd support this. Guava is pretty handy in my experience


On Fri, Apr 12, 2013 at 8:22 AM, John May <johnmay@ebi.ac.uk> wrote:
Hi All,

How would you feel about adding guava to CDK?https://code.google.com/p/guava-libraries/

I use this in every other projects as the utilities it provides are extremely useful and make life a lot easier. In fact some of features them have been ported to java 7 and more will be in java 8.

If you already use it, then you already know how awesome it is. If not, here are some of the features I think make it worth it. They explain all the features here:https://code.google.com/p/guava-libraries/wiki/GuavaExplained

Argument checking,

if(arg == null)
thrown new NullPointerException("argument require");

Can be inlined

public Element(String symbol, Integer atomicNumber) {
this.symbol = checkNotNull(symbol, "no symbol");// throws NPE if null
this.atomicNumber =checkNotNull(atomicNumber,"no atomic number");
}

You can also check argument values
checkArugment("C".equals(symbol), "symbol was not carbon"); // throws IllegalArgumentEx if false

Correct hash size, if I want 100 item hash new HashMap(100); is incorrect as you need to allow space forcollision. If you give the java HashMap a size of 100 it will resize once it hits 75% full, that's an entire rehash!
int n =container.getAtomCount();
Map<IAtom,Interger> indexMap = Maps.newHashMapWithExpectedSize(n);

Primitive utilities - much nicer handling of pimitives
Ints.asList(new int[0]);
Ints.compare(u, v);
int[] arr = Int.toArray(List<Interger> xs)

Multimap, key->collection maps are very common
Multimap<Interger,IAtom> map = Maps.newHashMultimap();

functions and predicate - okay well this only really makes sense with immutable values but you as an example one could wrap the fingerprints in a function and apply it to a collection
Function<IAtomContainer,BitSet> fp = ;
List<IAtomContainer> containers
List<BitSet> fps = Collections2.transform(containers, fp);

FluentIterable - really nice iterator handling:

Thoughts?

Thanks,
J

------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Cdk-devel mailing list
Cdk-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-devel




--
Rajarshi Guha | http://blog.rguha.net
NIH Center for Advancing Translational Science