mapParents

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

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.

Return

The collected parents in order.

Parameters

T

Key and value type of the Map.

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.

Throws

In case failIfCyclic is true and a cycle is detected.