By persistent collections I mean collections like those in clojure.
For example, I have a list with the elements (a,b,c). With a normal list, if I add d, my original
totallylazy is a very good FP library which has implementations of:
PersistentList: the concrete implementations are LinkedList and TreeList (for random access)PersistentMap: the concrete implementations are HashTreeMap and ListMapPersistentSortedMapPersistentSet: the concrete implementation is TreeSetExample of usage:
import static com.googlecode.totallylazy.collections.PersistentList.constructors.*;
import com.googlecode.totallylazy.collections.PersistentList;
import com.googlecode.totallylazy.numbers.Numbers;
...
PersistentList list = list(1, 2, 3);
// Create a new list with 0 prepended
list = list.cons(0);
// Prints 0::1::2::3
System.out.println(list);
// Do some actions on this list (e.g. remove all even numbers)
list = list.filter(Numbers.odd);
// Prints 1::3
System.out.println(list);
totallylazy is constantly being maintained. The main disadvantage is the total absence of Javadoc.