Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ AddIfNotPresent()

virtual bool System.Collections.Generic.SortedSet< T >.AddIfNotPresent ( T item)
inlinepackagevirtual

Reimplemented in System.Collections.Generic.SortedSet< T >.TreeSubSet, and System.Collections.Generic.TreeSet< T >.

Definition at line 918 of file SortedSet.cs.

919 {
920 if (root == null)
921 {
922 root = new Node(item, NodeColor.Black);
923 count = 1;
924 version++;
925 return true;
926 }
927 Node node = root;
928 Node parent = null;
929 Node node2 = null;
930 Node greatGrandParent = null;
931 version++;
932 int num = 0;
933 while (node != null)
934 {
935 num = comparer.Compare(item, node.Item);
936 if (num == 0)
937 {
939 return false;
940 }
941 if (node.Is4Node)
942 {
943 node.Split4Node();
944 if (Node.IsNonNullRed(parent))
945 {
947 }
948 }
950 node2 = parent;
951 parent = node;
952 node = ((num < 0) ? node.Left : node.Right);
953 }
954 Node node3 = new Node(item, NodeColor.Red);
955 if (num > 0)
956 {
958 }
959 else
960 {
962 }
963 if (parent.IsRed)
964 {
966 }
968 count++;
969 return true;
970 }
NodeColor
Definition RBTree.cs:10
void InsertionBalance(Node current, ref Node parent, Node grandParent, Node greatGrandParent)

References System.Collections.Generic.SortedSet< T >.Node.ColorBlack(), System.Collections.Generic.IComparer< in T >.Compare(), System.Collections.Generic.SortedSet< T >.comparer, System.Collections.Generic.SortedSet< T >.count, System.Runtime.Serialization.Dictionary, System.Collections.Generic.SortedSet< T >.InsertionBalance(), System.Collections.Generic.SortedSet< T >.Node.IsNonNullRed(), System.Collections.Generic.SortedSet< T >.Node.IsRed, System.item, System.Collections.Generic.SortedSet< T >.root, and System.Collections.Generic.SortedSet< T >.version.

Referenced by System.Collections.Generic.SortedSet< T >.Add().