RiSE4fun samples for HeapDbgList of built-in samples for the HeapDbg in RiSE4funen-USrise4fun &copy; 2017 Microsoft Corporationhttp://rise4fun.com//Images/Rise.gifRiSE4fun samples for HeapDbghttp://rise4fun.com/HeapDbg/ArrayOfDataArrayOfData// Creates an array of un-aliased Data objects class Data { } class Program { static object Run() { var res = new Data[10]; for (int i = 0; i < res.Length; ++i) res[i] = new Data(); return new { root = res }; } }http://rise4fun.com/HeapDbg/HelloWorldHelloWorld// Creates a heap and returns each root as a field of the return object class Hello { public World World; } class World { } class Program { static object Run() { var res = new Hello { World = new World() }; return new { root = res }; } }http://rise4fun.com/HeapDbg/ArrayOfDataWithNullEntriesArrayOfDataWithNullEntries// Creates an array of un-aliased Data objects, some entries are null. class Data { } class Program { static object Run() { var res = new Data[10]; for (int i = 0; i < 10; ++i) { if (i % 2 != 0 && i % 3 != 0) res[i] = new Data(); } return new { root = res }; } } http://rise4fun.com/HeapDbg/LinkedListLinkedList// Create a LinkedList of Data objects // Self edge on, Next, and label, List class Data { } class ListNode { public ListNode Next; public Data Data; } class Program { static object Run() { ListNode res = null; for (int i = 0; i < 10; ++i) res = new ListNode { Next = res, Data = new Data() }; return new { root = res }; } } http://rise4fun.com/HeapDbg/ArrayOfDataAliasedArrayOfDataAliased// Create an array of aliased Data objects // Alising is shown as XXX color on [?] edge. class Data { public int Value; } class Program { static object Run() { var res = new Data[10]; for (int i = 0; i < res.Length; ++i) { if (i % 2 == 0) res[i] = new Data(); else res[i] = res[i - 1]; } return new { root = res }; } } http://rise4fun.com/HeapDbg/ArrayOfDataWithSpecialArrayOfDataWithSpecial// Create an array of un-aliased Data objects and one special object class Data { public int val;} class Program { static object Run() { var resa = new Data[10]; var dspecial = new Data(); for (int i = 0; i < resa.Length; ++i) { if (i == 5) resa[i] = dspecial; else resa[i] = new Data(); } return new { array = resa, special = dspecial }; } } http://rise4fun.com/HeapDbg/TreeTree// Creates a Tree of Data objects class Data { } class TreeNode { public TreeNode Left; public TreeNode Right; public Data Data; public static TreeNode MakeTree(int k) { if (k <= 0) return null; else return new TreeNode { Left = MakeTree(k - 1), Right = MakeTree(k - 1), Data = new Data() }; } } class Program { static object Run() { return new { root = TreeNode.MakeTree(3) }; } } http://rise4fun.com/HeapDbg/ArrayOfSameColorSphereObjectsArrayOfSameColorSphereObjects//Create an array of un-aliased and aliased Shperes. // Each a composite object of an unaliased Point object but a shared Color object. class Program { static object Run() { var spheres = new Sphere[10]; var rgb = new Color { red = 0, blue = 255, green = 0 }; for (int i = 0; i < 10; ++i) { var ctr = new Point { xpos = i, ypos = i + 1, zpos = i - 1 }; spheres[i] = new Sphere { center = ctr, color = rgb, radius = 3.0F }; } return new { root = spheres }; } } class Sphere { public Point center; public Color color; public float radius; } class Color { public int red; public int blue; public int green; } class Point { public float xpos; public float ypos; public float zpos; } http://rise4fun.com/HeapDbg/ArrayOfSpheresArrayOfSpheres// Create an array of un-aliased Shperes. // Each a composite object of an unaliased Point object and Color object class Color { public int red; public int blue; public int green; } class Point { public float xpos; public float ypos; public float zpos; } class Sphere { public Point center; public Color color; public float radius; } class Program { static object Run() { var spheres = new Sphere[10]; for (int i = 0; i < spheres.Length; ++i) { var ctr = new Point { xpos = i, ypos = i + 1, zpos = i - 1 }; var rgb = new Color { red = i, blue = i, green = i }; spheres[i] = new Sphere { center = ctr, color = rgb, radius = 3.0F }; } return new { spheres = spheres }; } } http://rise4fun.com/HeapDbg/TreeCopyDeepTreeCopyDeep// Creates a Deep Copy of a Tree of Data objects class Data { public int Value;} class TreeNode { public TreeNode Left; public TreeNode Right; public Data Data; public static TreeNode MakeTree(int k) { if (k == 0) return null; else return new TreeNode { Left = MakeTree(k - 1), Right = MakeTree(k - 1), Data = new Data() }; } public static TreeNode CopyTreeDeep(TreeNode t) { if (t == null) return null; else return new TreeNode { Left = CopyTreeDeep(t.Left), Right = CopyTreeDeep(t.Right), Data = new Data { Value = t.Data.Value } }; } } class Program { static object Run() { var original = TreeNode.MakeTree(3); var copy = TreeNode.CopyTreeDeep(original); return new { original = original, copy = copy }; } } http://rise4fun.com/HeapDbg/NestedTreeofArraysOfSameColorSphereObjectsNestedTreeofArraysOfSameColorSphereObjects// Create an tree containing nested arrays of speheres // Everything is nested/unaliased but they all share a special color object using System; class Program { static object Run() { var special = new Color { red = 0, blue = 255, green = 0 }; var rtn = STreeNode.MakeTree(3, special); return new { tree = rtn, scolor = special }; } } class STreeNode { public STreeNode left; public STreeNode right; public Sphere[] data; public static STreeNode MakeTree(int k, Color c) { if (k == 0) return null; else { var sph = new Sphere[5]; for (int i = 0; i < sph.Length; ++i) { var cp = new Point { xpos = k, ypos = k, zpos = k }; sph[i] = new Sphere { center = cp, color = c, radius = 1F }; } return new STreeNode { left = MakeTree(k - 1, c), right = MakeTree(k - 1, c), data = sph }; } } } class Sphere { public Point center; public Color color; public float radius; } class Color { public int red; public int blue; public int green; } class Point { public float xpos; public float ypos; public float zpos; } http://rise4fun.com/HeapDbg/DictionaryOfArraysOfSameColorSphereObjectsDictionaryOfArraysOfSameColorSphereObjects// Create a scene structure for a simple raytracer class Program { static object Run() { ISceneObject[] things = { new Sphere { Center = new Vector { X = -0.5F, Y = 1F, Z = 1.5F }, RGB = new Color { Red = 0, Blue = 255, Green = 0 }, Radius = 0.5F }, new Sphere { Center = new Vector { X = 0F, Y = 1F, Z = -0.25F }, RGB = new Color { Red = 0, Blue = 0, Green = 255 }, Radius = 1F }, new Plane { Norm = new Vector { X = 0F, Y = 1F, Z = 0F }, RGB = new Color { Red = 192, Blue = 192, Green = 192 }, Offset = 1F } }; Light[] lights = { new Light { Pos = new Vector { X = -2F, Y = 2.5F, Z = 0F }, RGB = new Color { Red = 173, Blue = 216, Green = 230 } }, new Light { Pos = new Vector { X = 2F, Y = 4.5F, Z = 2F }, RGB = new Color { Red = 255, Blue = 127, Green = 0 } } }; var camera = new Camera { Pos = new Vector { X = 2.75F, Y = 2F, Z = 3.75F }, Forward = new Vector { X = -0.6F, Y = 0.5F, Z = 0F } }; return new { root = new Scene { Things = things, Lights = lights, Camera = camera } }; } } class Scene { public ISceneObject[] Things; public Light[] Lights; public Camera Camera; } interface ISceneObject { } class Sphere : ISceneObject { public Vector Center; public Color RGB; public float Radius; } class Plane : ISceneObject { public Vector Norm; public Color RGB; public float Offset; } class Light { public Vector Pos; public Color RGB; } class Camera { public Vector Pos; public Vector Forward; } class Vector { public float X; public float Y; public float Z; } class Color { public int Red; public int Blue; public int Green; }