Skip to content

Commit

Permalink
niknaks.containers
Browse files Browse the repository at this point in the history
- Work in prog on new `CycleDetectiobnTree`
  • Loading branch information
deavmi committed Oct 17, 2024
1 parent 65a625e commit ee90150
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions source/niknaks/containers.d
Original file line number Diff line number Diff line change
Expand Up @@ -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`
*/
Expand Down

0 comments on commit ee90150

Please sign in to comment.