Frontier
Typeclass: abstracts over frontier data structures (Queue, Stack, PriorityQueue). The three implementations below give us BFS, DFS, and best-first / Dijkstra-style traversals for free — the traversal algorithm itself doesn't change at all.
Type parameters
- F
-
the higher-kinded frontier container type
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Members list
Value members
Abstract methods
Returns an empty instance of the parameterized type wrapped in the context of the effect type F.
Returns an empty instance of the parameterized type wrapped in the context of the effect type F.
Attributes
- Returns
-
An empty instance of
F[T].
Checks if the given frontier is empty.
Checks if the given frontier is empty.
Value parameters
- f
-
the frontier to be checked for emptiness
Attributes
- Returns
-
true if the frontier is empty, false otherwise
Applies a given value to a the frontier f.
Applies a given value to a the frontier f.
Value parameters
- f
-
The frontier of type
F[T]that will receive the value. - t
-
The value of type
Tto be applied to the frontierf.
Attributes
- Returns
-
A new frontier
Fthat incorporates the provided valuet.
Extracts an element of type T from the frontier F[T] and returns a tuple, where the first element is the extracted value of type T and the second element is the remaining frontier of type F[T] after the extraction.
Extracts an element of type T from the frontier F[T] and returns a tuple, where the first element is the extracted value of type T and the second element is the remaining frontier of type F[T] after the extraction.
Value parameters
- f
-
the input frontier of type
F[T]from which an element is extracted
Attributes
- Returns
-
a tuple containing the extracted element of type
Tand the remaining frontier of typeF[T]
Concrete methods
Adds all elements from the given list to the provided frontier. The order in which the elements are added depends on the value of reverseOnOffer. If reverseOnOffer is true, the elements are added in reverse order; otherwise, they are added as-is.
Adds all elements from the given list to the provided frontier. The order in which the elements are added depends on the value of reverseOnOffer. If reverseOnOffer is true, the elements are added in reverse order; otherwise, they are added as-is.
Value parameters
- f
-
The initial frontier of type
F[T]to which the elements will be added. - ts
-
A list of elements of type
Tto add to the frontier.
Attributes
- Returns
-
A new frontier of type
F[T]that includes all elements from the listts, added in the specified order.
Determines whether elements should be reversed upon being added to the frontier. This behavior is typically useful in certain traversal algorithms where the order of elements affects the outcome, such as depth-first or breadth-first search.
Determines whether elements should be reversed upon being added to the frontier. This behavior is typically useful in certain traversal algorithms where the order of elements affects the outcome, such as depth-first or breadth-first search.
Attributes
- Returns
-
true if elements are reversed when offered to the frontier, false otherwise