class FlattenedList<A> : TransformationList<A, ObservableValue<out A>>
FlattenedList flattens the passed in list of ObservableValues so that changes in individual updates to the values are reflected in the exposed list as expected.
WrappedObservableValue |
class WrappedObservableValue<A> We maintain an ObservableValue->index map. This is needed because we need the ObservableValues index in order to propagate a change and if the listener closure captures the index at the time of the call to ObservableValue.addListener it will become incorrect if the indices shift around later. |
<init> |
FlattenedList(sourceList: ObservableList<out ObservableValue<out A>>) FlattenedList flattens the passed in list of ObservableValues so that changes in individual updates to the values are reflected in the exposed list as expected. |
indexMap |
val indexMap: HashMap<WrappedObservableValue<out A>, <ERROR CLASS><Int, ChangeListener<A>>> |
size |
val size: Int |
sourceList |
val sourceList: ObservableList<out ObservableValue<out A>> |
get |
fun get(index: Int): A |
getSourceIndex |
fun getSourceIndex(index: Int): Int |
sourceChanged |
fun sourceChanged(c: Change<out ObservableValue<out A>>): Unit |
filter |
fun <A> ObservableList<out A>.filter(predicate: ObservableValue<(A) -> Boolean>): ObservableList<out A> enum class FilterCriterion { HEIGHT, NAME } val filterCriterion: ObservableValue = (..) val people: ObservableList = (..) fun filterFunction(filterCriterion: FilterCriterion): (Person) -> Boolean { .. } |
fold |
fun <A, B> ObservableList<out A>.fold(initial: B, folderFunction: (B, A) -> B): ObservableValue<B> val people: ObservableList = (..) val concatenatedNames = people.fold("", { names, person -> names + person.name }) val concatenatedNames2 = people.map(Person::name).fold("", String::plus) |
indexOfOrThrow |
fun <T> List<T>.indexOfOrThrow(item: T): Int Returns the index of the given item or throws IllegalArgumentException if not found. |
map |
fun <A, B> ObservableList<out A>.map(function: (A) -> B): ObservableList<B> val dogs: ObservableList = (..) val dogOwners: ObservableList = dogs.map { it.owner } |
noneOrSingle |
fun <T> Iterable<T>.noneOrSingle(predicate: (T) -> Boolean): T? Returns the single element matching the given predicate, or fun <T> Iterable<T>.noneOrSingle(): T? Returns single element, or |