title: java: libraries for immutable functional-style data structures
body: <p>This is very similar to another question (<a href="https://stackoverflow.com/questions/1683430/functional-data-structures-in-java">Functional Data Structures in Java</a>) but the answers there are not particularly useful.</p>
  
  <p>I need to use immutable versions of the standard Java collections (e.g. HashMap / TreeMap / ArrayList / LinkedList / HashSet / TreeSet). By "immutable" I mean immutable in the functional sense (e.g. <a href="http://en.wikipedia.org/wiki/Purely_functional" rel="nofollow noreferrer">purely functional data structures</a>), where updating operations on the data structure do not change the original data, but instead return a new instance of the same kind of data structure. Also typically new and old instances of the data structure will share immutable data to be efficient in time and space.</p>
  
  <p>From what I can tell my options include:</p>
  
  <ul>
  <li><a href="http://functionaljava.org/" rel="nofollow noreferrer">Functional Java</a></li>
  <li><a href="http://www.scala-lang.org/" rel="nofollow noreferrer">Scala</a></li>
  <li><a href="http://clojure.org/" rel="nofollow noreferrer">Clojure</a></li>
  </ul>
  
  <p>but I'm not sure whether any of these are particularly appealing to me. I have a few requirements/desirements:</p>
  
  <ul>
  <li><p><strong>the collections in question should be usable directly in Java</strong> (with the appropriate libraries in the classpath). FJ would work for me; I'm not sure if I can use Scala's or Clojure's data structures in Java w/o having to use the compilers/interpreters from those languages and w/o having to write Scala or Clojure code.</p></li>
  <li><p><strong>Core operations on lists/maps/sets should be possible w/o having to create function objects with confusing syntaxes</strong> (FJ looks slightly iffy)</p></li>
  <li><p><strong>They should be efficient in time and space.</strong> I'm looking for a library which ideally has done some performance testing. FJ's <a href="http://functionaljava.googlecode.com/svn/artifacts/2.22/javadoc/index.html" rel="nofollow noreferrer">TreeMap</a> is based on a red-black tree, not sure how that rates.</p></li>
  <li><p><strong>Documentation / tutorials should be good enough so someone can get started quickly using the data structures.</strong> FJ fails on that front.</p></li>
  </ul>
  
  <p>Any suggestions?</p>