From ee90150ac0c86716e39a715c8187645c6415a3dd Mon Sep 17 00:00:00 2001 From: Tristan Brice Velloza Kildaire Date: Thu, 17 Oct 2024 15:25:54 +0200 Subject: [PATCH] niknaks.containers - Work in prog on new `CycleDetectiobnTree` --- source/niknaks/containers.d | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/source/niknaks/containers.d b/source/niknaks/containers.d index 0a192f2..84ffd53 100644 --- a/source/niknaks/containers.d +++ b/source/niknaks/containers.d @@ -1297,6 +1297,37 @@ unittest assert(linearized[1] == "root"); } +public class CycleDetectionTree(T) : Graph!(T) +{ + private size_t cnt; + + /** + * Constructs a new node + * + * Params: + * value = the value + */ + this(T value) + { + super(value); + } + + public void mark() + { + this.cnt++; + } + + public bool isVisited() + { + return this.cnt > 0; + } + + public bool wasCycled() + { + return this.cnt > 1; + } +} + /** * Basic implementation of a `SectorType` */