Hey,
I'm pretty new to c#, and i'm trying to understand something pretty basic.
I want to implement a RBTree and a linked list , so i create :
public class RBTreeNode
{
// PROPERTIES
public RBTreeNode left;
public RBTreeNode right;
public RBTreeNode parent;
public String Color;
public Int Key;
}
List<RBTreeNode> deleteList = new List<RBTreeNode>();
During the running of my program i iterate through the tree, taking some nodes (depending on the value) , and adding them to deleteList.
the thing that i can't set my mind to, is if for example i have RBTreeNode X , and i do X.left = null. the thing i want to happen is nulling X's left child (without affecting X.left RBTreeNode , but what i think will happen here is that indeed X.left will become null, but the X.left RBTreeNode object will become also null. which is not what i want. (if it's copied to deleteList , it will become null, which is wrong)
I want to be able to do the same thing i do with c++ using pointers. In c++ i might do it like :
public class RBTreeNode
{
// PROPERTIES
public RBTreeNode* left;
public RBTreeNode* right;
public RBTreeNode* parent;
public std::string Color;
public int Key;
}
For example :
RBTreeNode* tenp = X->left;
X->left = null; //(i think in c# it will turn temp here to null to - of course without pointers)
temp->right = &X;
Any tips/explanations ?