From 2020b7ff2738fc46f5185d430db74d980272e7a5 Mon Sep 17 00:00:00 2001 From: tulip Date: Mon, 3 Jun 2024 20:20:05 +0800 Subject: [PATCH] feat: use contains method. --- paths.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/paths.go b/paths.go index 130547d..c8d9868 100644 --- a/paths.go +++ b/paths.go @@ -256,16 +256,9 @@ func AllPathsBetween[K comparable, T any](g Graph[K, T], start, end K) ([][]K, e newElements := newStack[K]() for e := range adjacencyMap[element] { - var contains bool - mainStack.forEach(func(k K) { - if e == k { - contains = true - } - }) - if contains { - continue + if !mainStack.contains(e) { + newElements.push(e) } - newElements.push(e) } viceStack.push(newElements) }