kbox-android / ch.tutteli.kbox / kotlin.collections.Map / mapParents

mapParents

fun <T> Map<T, T>.mapParents(child: T, failIfCyclic: Boolean = false): LinkedHashSet<T>

It is assumed that the Map represents a child parent relation where this function returns a LinkedHashSet with all collected parents.

A key represent a child and the value its parent.

Parameters

child - Defines the starting point of the search.

failIfCyclic - false per default but can be set to true in which case it throws an IllegalStateException if a cycle is detected.

Exceptions

IllegalStateException - In case failIfCyclic is true and a cycle is detected.

Return
The collected parents in order.