Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Tree Node Sample
//Title of this code //Rextester.Program.Main is the entry point for your code. Don't change it. using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public abstract class TreeNode<T> { public T State { get; set; } public TreeNode<T> Parent; public int Cost { get; set; } public int Depth { get; set; } public int F { get; set; } protected void SetState (T state) { this.State = state; } protected void InitFirstNode () { this.Cost = 0; this.Depth = 0; } public abstract bool CompareTo (TreeNode<T> obj); public abstract bool CompareTo (T state); } public class SlidingPuzzleNode : TreeNode<int> { public SlidingPuzzleNode (int state) { SetState(state); InitFirstNode(); } private void CalculateStatus (SlidingPuzzleNode parent) { this.Cost = parent.Cost + 1; this.Depth = parent.Depth + 1; } public SlidingPuzzleNode (int state, SlidingPuzzleNode parent) { SetState(state); CalculateStatus(parent); } public override bool CompareTo (TreeNode<int> obj) { return CompareTo(obj.State); } public override bool CompareTo (int state) { return this.State == state; } } public class Program { public static void Main(string[] args) { var a = 90; var x = new SlidingPuzzleNode(a); var y = new SlidingPuzzleNode(a + 1, x); Console.WriteLine(y.CompareTo(x)); } } }
run
|
edit
|
history
|
help
0
іфи
SDAXXX
Ejercicio bucles
TCP
p link gener tor
Is first character of MD5 hash evenly distributed?
Type win
Animal generator (Under construction!)
events
Get a webpage - the async way