java.util.List Extensions

Adds various function extensions to java.util.List implementations.

Function Summary
java.util.List asImmutable()
Returns an immutable version of this list.
java.util.List asSynchronized()
Returns a synchronized version of this list.
Object pop()
Pops the last item off the list.
java.util.List sort()
Sorts the list according to the natural order.
java.util.List sortEach(Function func)
Sorts the list using the passed function to determine order.

Functions

asImmutable

java.util.List asImmutable()

Returns an immutable version of this list.

Example:
frozenList = list.asImmutable()

asSynchronized

java.util.List asSynchronized()

Returns a synchronized version of this list.

Example:
multiThreadList = list.asSynchronized()

pop

Object pop()

Pops the last item off the list. The last item will be returned and removed from the list.

Example:
lastItem = list.pop()

sort

java.util.List sort()

Sorts the list according to the natural order.

Example:
sortedList = list.sort()

sortEach

java.util.List sortEach(Function func)

Sorts the list using the passed function to determine order. The function will receive two parameters, and should return > 0 if the first is greater, < 0 if the first is less, and 0 if equal.

Example:
sortedList = list.sort(function(val1, val2) { return val1.compareTo(val2) })