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

◆ DoRemove()

virtual bool System.Collections.Generic.SortedSet< T >.DoRemove ( T item)
inlinepackagevirtualinherited

Reimplemented in System.Collections.Generic.SortedSet< T >.TreeSubSet.

Definition at line 977 of file SortedSet.cs.

978 {
979 if (root == null)
980 {
981 return false;
982 }
983 version++;
984 Node node = root;
985 Node node2 = null;
986 Node node3 = null;
987 Node node4 = null;
988 Node parentOfMatch = null;
989 bool flag = false;
990 while (node != null)
991 {
992 if (node.Is2Node)
993 {
994 if (node2 == null)
995 {
996 node.ColorRed();
997 }
998 else
999 {
1000 Node sibling = node2.GetSibling(node);
1001 if (sibling.IsRed)
1002 {
1003 if (node2.Right == sibling)
1004 {
1005 node2.RotateLeft();
1006 }
1007 else
1008 {
1009 node2.RotateRight();
1010 }
1011 node2.ColorRed();
1012 sibling.ColorBlack();
1014 node3 = sibling;
1015 if (node2 == node4)
1016 {
1018 }
1019 sibling = node2.GetSibling(node);
1020 }
1021 if (sibling.Is2Node)
1022 {
1023 node2.Merge2Nodes();
1024 }
1025 else
1026 {
1027 Node node5 = node2.Rotate(node2.GetRotation(node, sibling));
1028 node5.Color = node2.Color;
1029 node2.ColorBlack();
1030 node.ColorRed();
1032 if (node2 == node4)
1033 {
1035 }
1036 node3 = node5;
1037 }
1038 }
1039 }
1040 int num = (flag ? (-1) : comparer.Compare(item, node.Item));
1041 if (num == 0)
1042 {
1043 flag = true;
1044 node4 = node;
1046 }
1047 node3 = node2;
1048 node2 = node;
1049 node = ((num < 0) ? node.Left : node.Right);
1050 }
1051 if (node4 != null)
1052 {
1054 count--;
1055 }
1056 root?.ColorBlack();
1057 return flag;
1058 }
void ReplaceChildOrRoot(Node parent, Node child, Node newChild)
void ReplaceNode(Node match, Node parentOfMatch, Node successor, Node parentOfSuccessor)

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.item, System.Collections.Generic.SortedSet< T >.ReplaceChildOrRoot(), System.Collections.Generic.SortedSet< T >.ReplaceNode(), System.Collections.Generic.SortedSet< T >.root, and System.Collections.Generic.SortedSet< T >.version.

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