Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Tuple.cs
Go to the documentation of this file.
5using System.Text;
6
7namespace System;
8
9public static class Tuple
10{
11 public static Tuple<T1> Create<T1>(T1 item1)
12 {
13 return new Tuple<T1>(item1);
14 }
15
17 {
18 return new Tuple<T1, T2>(item1, item2);
19 }
20
22 {
23 return new Tuple<T1, T2, T3>(item1, item2, item3);
24 }
25
30
35
40
45
50
51 internal static int CombineHashCodes(int h1, int h2)
52 {
53 return ((h1 << 5) + h1) ^ h2;
54 }
55
56 internal static int CombineHashCodes(int h1, int h2, int h3)
57 {
59 }
60
61 internal static int CombineHashCodes(int h1, int h2, int h3, int h4)
62 {
64 }
65
66 internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5)
67 {
69 }
70
71 internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6)
72 {
74 }
75
76 internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7)
77 {
79 }
80
81 internal static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8)
82 {
84 }
85}
86[Serializable]
87[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
89{
90 private readonly T1 m_Item1;
91
92 public T1 Item1 => m_Item1;
93
94 int ITuple.Length => 1;
95
96 object? ITuple.this[int index]
97 {
98 get
99 {
100 if (index != 0)
101 {
102 throw new IndexOutOfRangeException();
103 }
104 return Item1;
105 }
106 }
107
108 public Tuple(T1 item1)
109 {
110 m_Item1 = item1;
111 }
112
113 public override bool Equals([NotNullWhen(true)] object? obj)
114 {
116 }
117
122
123 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
124 {
125 if (other == null)
126 {
127 return false;
128 }
129 if (!(other is Tuple<T1> tuple))
130 {
131 return false;
132 }
133 return comparer.Equals(m_Item1, tuple.m_Item1);
134 }
135
137 {
139 }
140
145
146 private int CompareTo(object other, IComparer comparer)
147 {
148 if (other == null)
149 {
150 return 1;
151 }
152 if (!(other is Tuple<T1> tuple))
153 {
154 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
155 }
156 return comparer.Compare(m_Item1, tuple.m_Item1);
157 }
158
159 public override int GetHashCode()
160 {
162 }
163
168
173
175 {
176 return comparer.GetHashCode(m_Item1);
177 }
178
179 public override string ToString()
180 {
182 stringBuilder.Append('(');
183 return ToString(stringBuilder);
184 }
185
187 {
188 return ToString(sb);
189 }
190
191 private string ToString(StringBuilder sb)
192 {
193 sb.Append(m_Item1);
194 sb.Append(')');
195 return sb.ToString();
196 }
197}
198[Serializable]
199[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
201{
202 private readonly T1 m_Item1;
203
204 private readonly T2 m_Item2;
205
206 public T1 Item1 => m_Item1;
207
208 public T2 Item2 => m_Item2;
209
210 int ITuple.Length => 2;
211
212 object? ITuple.this[int index] => index switch
213 {
214 0 => Item1,
215 1 => Item2,
216 _ => throw new IndexOutOfRangeException(),
217 };
218
219 public Tuple(T1 item1, T2 item2)
220 {
221 m_Item1 = item1;
222 m_Item2 = item2;
223 }
224
225 public override bool Equals([NotNullWhen(true)] object? obj)
226 {
228 }
229
234
235 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
236 {
237 if (other == null)
238 {
239 return false;
240 }
242 {
243 return false;
244 }
245 if (comparer.Equals(m_Item1, tuple.m_Item1))
246 {
247 return comparer.Equals(m_Item2, tuple.m_Item2);
248 }
249 return false;
250 }
251
253 {
255 }
256
261
262 private int CompareTo(object other, IComparer comparer)
263 {
264 if (other == null)
265 {
266 return 1;
267 }
269 {
270 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
271 }
272 int num = comparer.Compare(m_Item1, tuple.m_Item1);
273 if (num != 0)
274 {
275 return num;
276 }
277 return comparer.Compare(m_Item2, tuple.m_Item2);
278 }
279
280 public override int GetHashCode()
281 {
283 }
284
289
294
296 {
297 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2));
298 }
299
300 public override string ToString()
301 {
303 stringBuilder.Append('(');
304 return ToString(stringBuilder);
305 }
306
308 {
309 return ToString(sb);
310 }
311
312 private string ToString(StringBuilder sb)
313 {
314 sb.Append(m_Item1);
315 sb.Append(", ");
316 sb.Append(m_Item2);
317 sb.Append(')');
318 return sb.ToString();
319 }
320}
321[Serializable]
322[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
324{
325 private readonly T1 m_Item1;
326
327 private readonly T2 m_Item2;
328
329 private readonly T3 m_Item3;
330
331 public T1 Item1 => m_Item1;
332
333 public T2 Item2 => m_Item2;
334
335 public T3 Item3 => m_Item3;
336
337 int ITuple.Length => 3;
338
339 object? ITuple.this[int index] => index switch
340 {
341 0 => Item1,
342 1 => Item2,
343 2 => Item3,
344 _ => throw new IndexOutOfRangeException(),
345 };
346
347 public Tuple(T1 item1, T2 item2, T3 item3)
348 {
349 m_Item1 = item1;
350 m_Item2 = item2;
351 m_Item3 = item3;
352 }
353
354 public override bool Equals([NotNullWhen(true)] object? obj)
355 {
357 }
358
363
364 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
365 {
366 if (other == null)
367 {
368 return false;
369 }
371 {
372 return false;
373 }
374 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2))
375 {
376 return comparer.Equals(m_Item3, tuple.m_Item3);
377 }
378 return false;
379 }
380
382 {
384 }
385
390
391 private int CompareTo(object other, IComparer comparer)
392 {
393 if (other == null)
394 {
395 return 1;
396 }
398 {
399 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
400 }
401 int num = comparer.Compare(m_Item1, tuple.m_Item1);
402 if (num != 0)
403 {
404 return num;
405 }
406 num = comparer.Compare(m_Item2, tuple.m_Item2);
407 if (num != 0)
408 {
409 return num;
410 }
411 return comparer.Compare(m_Item3, tuple.m_Item3);
412 }
413
414 public override int GetHashCode()
415 {
417 }
418
423
428
430 {
431 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3));
432 }
433
434 public override string ToString()
435 {
437 stringBuilder.Append('(');
438 return ToString(stringBuilder);
439 }
440
442 {
443 return ToString(sb);
444 }
445
446 private string ToString(StringBuilder sb)
447 {
448 sb.Append(m_Item1);
449 sb.Append(", ");
450 sb.Append(m_Item2);
451 sb.Append(", ");
452 sb.Append(m_Item3);
453 sb.Append(')');
454 return sb.ToString();
455 }
456}
457[Serializable]
458[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
460{
461 private readonly T1 m_Item1;
462
463 private readonly T2 m_Item2;
464
465 private readonly T3 m_Item3;
466
467 private readonly T4 m_Item4;
468
469 public T1 Item1 => m_Item1;
470
471 public T2 Item2 => m_Item2;
472
473 public T3 Item3 => m_Item3;
474
475 public T4 Item4 => m_Item4;
476
477 int ITuple.Length => 4;
478
479 object? ITuple.this[int index] => index switch
480 {
481 0 => Item1,
482 1 => Item2,
483 2 => Item3,
484 3 => Item4,
485 _ => throw new IndexOutOfRangeException(),
486 };
487
488 public Tuple(T1 item1, T2 item2, T3 item3, T4 item4)
489 {
490 m_Item1 = item1;
491 m_Item2 = item2;
492 m_Item3 = item3;
493 m_Item4 = item4;
494 }
495
496 public override bool Equals([NotNullWhen(true)] object? obj)
497 {
499 }
500
505
506 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
507 {
508 if (other == null)
509 {
510 return false;
511 }
513 {
514 return false;
515 }
516 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2) && comparer.Equals(m_Item3, tuple.m_Item3))
517 {
518 return comparer.Equals(m_Item4, tuple.m_Item4);
519 }
520 return false;
521 }
522
524 {
526 }
527
532
533 private int CompareTo(object other, IComparer comparer)
534 {
535 if (other == null)
536 {
537 return 1;
538 }
540 {
541 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
542 }
543 int num = comparer.Compare(m_Item1, tuple.m_Item1);
544 if (num != 0)
545 {
546 return num;
547 }
548 num = comparer.Compare(m_Item2, tuple.m_Item2);
549 if (num != 0)
550 {
551 return num;
552 }
553 num = comparer.Compare(m_Item3, tuple.m_Item3);
554 if (num != 0)
555 {
556 return num;
557 }
558 return comparer.Compare(m_Item4, tuple.m_Item4);
559 }
560
561 public override int GetHashCode()
562 {
564 }
565
570
575
577 {
578 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4));
579 }
580
581 public override string ToString()
582 {
584 stringBuilder.Append('(');
585 return ToString(stringBuilder);
586 }
587
589 {
590 return ToString(sb);
591 }
592
593 private string ToString(StringBuilder sb)
594 {
595 sb.Append(m_Item1);
596 sb.Append(", ");
597 sb.Append(m_Item2);
598 sb.Append(", ");
599 sb.Append(m_Item3);
600 sb.Append(", ");
601 sb.Append(m_Item4);
602 sb.Append(')');
603 return sb.ToString();
604 }
605}
606[Serializable]
607[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
609{
610 private readonly T1 m_Item1;
611
612 private readonly T2 m_Item2;
613
614 private readonly T3 m_Item3;
615
616 private readonly T4 m_Item4;
617
618 private readonly T5 m_Item5;
619
620 public T1 Item1 => m_Item1;
621
622 public T2 Item2 => m_Item2;
623
624 public T3 Item3 => m_Item3;
625
626 public T4 Item4 => m_Item4;
627
628 public T5 Item5 => m_Item5;
629
630 int ITuple.Length => 5;
631
632 object? ITuple.this[int index] => index switch
633 {
634 0 => Item1,
635 1 => Item2,
636 2 => Item3,
637 3 => Item4,
638 4 => Item5,
639 _ => throw new IndexOutOfRangeException(),
640 };
641
642 public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
643 {
644 m_Item1 = item1;
645 m_Item2 = item2;
646 m_Item3 = item3;
647 m_Item4 = item4;
648 m_Item5 = item5;
649 }
650
651 public override bool Equals([NotNullWhen(true)] object? obj)
652 {
654 }
655
660
661 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
662 {
663 if (other == null)
664 {
665 return false;
666 }
668 {
669 return false;
670 }
671 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2) && comparer.Equals(m_Item3, tuple.m_Item3) && comparer.Equals(m_Item4, tuple.m_Item4))
672 {
673 return comparer.Equals(m_Item5, tuple.m_Item5);
674 }
675 return false;
676 }
677
679 {
681 }
682
687
688 private int CompareTo(object other, IComparer comparer)
689 {
690 if (other == null)
691 {
692 return 1;
693 }
695 {
696 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
697 }
698 int num = comparer.Compare(m_Item1, tuple.m_Item1);
699 if (num != 0)
700 {
701 return num;
702 }
703 num = comparer.Compare(m_Item2, tuple.m_Item2);
704 if (num != 0)
705 {
706 return num;
707 }
708 num = comparer.Compare(m_Item3, tuple.m_Item3);
709 if (num != 0)
710 {
711 return num;
712 }
713 num = comparer.Compare(m_Item4, tuple.m_Item4);
714 if (num != 0)
715 {
716 return num;
717 }
718 return comparer.Compare(m_Item5, tuple.m_Item5);
719 }
720
721 public override int GetHashCode()
722 {
724 }
725
730
735
737 {
738 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5));
739 }
740
741 public override string ToString()
742 {
744 stringBuilder.Append('(');
745 return ToString(stringBuilder);
746 }
747
749 {
750 return ToString(sb);
751 }
752
753 private string ToString(StringBuilder sb)
754 {
755 sb.Append(m_Item1);
756 sb.Append(", ");
757 sb.Append(m_Item2);
758 sb.Append(", ");
759 sb.Append(m_Item3);
760 sb.Append(", ");
761 sb.Append(m_Item4);
762 sb.Append(", ");
763 sb.Append(m_Item5);
764 sb.Append(')');
765 return sb.ToString();
766 }
767}
768[Serializable]
769[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
770public class Tuple<T1, T2, T3, T4, T5, T6> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple
771{
772 private readonly T1 m_Item1;
773
774 private readonly T2 m_Item2;
775
776 private readonly T3 m_Item3;
777
778 private readonly T4 m_Item4;
779
780 private readonly T5 m_Item5;
781
782 private readonly T6 m_Item6;
783
784 public T1 Item1 => m_Item1;
785
786 public T2 Item2 => m_Item2;
787
788 public T3 Item3 => m_Item3;
789
790 public T4 Item4 => m_Item4;
791
792 public T5 Item5 => m_Item5;
793
794 public T6 Item6 => m_Item6;
795
796 int ITuple.Length => 6;
797
798 object? ITuple.this[int index] => index switch
799 {
800 0 => Item1,
801 1 => Item2,
802 2 => Item3,
803 3 => Item4,
804 4 => Item5,
805 5 => Item6,
806 _ => throw new IndexOutOfRangeException(),
807 };
808
809 public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
810 {
811 m_Item1 = item1;
812 m_Item2 = item2;
813 m_Item3 = item3;
814 m_Item4 = item4;
815 m_Item5 = item5;
816 m_Item6 = item6;
817 }
818
819 public override bool Equals([NotNullWhen(true)] object? obj)
820 {
822 }
823
828
829 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
830 {
831 if (other == null)
832 {
833 return false;
834 }
836 {
837 return false;
838 }
839 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2) && comparer.Equals(m_Item3, tuple.m_Item3) && comparer.Equals(m_Item4, tuple.m_Item4) && comparer.Equals(m_Item5, tuple.m_Item5))
840 {
841 return comparer.Equals(m_Item6, tuple.m_Item6);
842 }
843 return false;
844 }
845
847 {
849 }
850
855
856 private int CompareTo(object other, IComparer comparer)
857 {
858 if (other == null)
859 {
860 return 1;
861 }
863 {
864 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
865 }
866 int num = comparer.Compare(m_Item1, tuple.m_Item1);
867 if (num != 0)
868 {
869 return num;
870 }
871 num = comparer.Compare(m_Item2, tuple.m_Item2);
872 if (num != 0)
873 {
874 return num;
875 }
876 num = comparer.Compare(m_Item3, tuple.m_Item3);
877 if (num != 0)
878 {
879 return num;
880 }
881 num = comparer.Compare(m_Item4, tuple.m_Item4);
882 if (num != 0)
883 {
884 return num;
885 }
886 num = comparer.Compare(m_Item5, tuple.m_Item5);
887 if (num != 0)
888 {
889 return num;
890 }
891 return comparer.Compare(m_Item6, tuple.m_Item6);
892 }
893
894 public override int GetHashCode()
895 {
897 }
898
903
908
910 {
911 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6));
912 }
913
914 public override string ToString()
915 {
917 stringBuilder.Append('(');
918 return ToString(stringBuilder);
919 }
920
922 {
923 return ToString(sb);
924 }
925
926 private string ToString(StringBuilder sb)
927 {
928 sb.Append(m_Item1);
929 sb.Append(", ");
930 sb.Append(m_Item2);
931 sb.Append(", ");
932 sb.Append(m_Item3);
933 sb.Append(", ");
934 sb.Append(m_Item4);
935 sb.Append(", ");
936 sb.Append(m_Item5);
937 sb.Append(", ");
938 sb.Append(m_Item6);
939 sb.Append(')');
940 return sb.ToString();
941 }
942}
943[Serializable]
944[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
945public class Tuple<T1, T2, T3, T4, T5, T6, T7> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple
946{
947 private readonly T1 m_Item1;
948
949 private readonly T2 m_Item2;
950
951 private readonly T3 m_Item3;
952
953 private readonly T4 m_Item4;
954
955 private readonly T5 m_Item5;
956
957 private readonly T6 m_Item6;
958
959 private readonly T7 m_Item7;
960
961 public T1 Item1 => m_Item1;
962
963 public T2 Item2 => m_Item2;
964
965 public T3 Item3 => m_Item3;
966
967 public T4 Item4 => m_Item4;
968
969 public T5 Item5 => m_Item5;
970
971 public T6 Item6 => m_Item6;
972
973 public T7 Item7 => m_Item7;
974
975 int ITuple.Length => 7;
976
977 object? ITuple.this[int index] => index switch
978 {
979 0 => Item1,
980 1 => Item2,
981 2 => Item3,
982 3 => Item4,
983 4 => Item5,
984 5 => Item6,
985 6 => Item7,
986 _ => throw new IndexOutOfRangeException(),
987 };
988
989 public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
990 {
991 m_Item1 = item1;
992 m_Item2 = item2;
993 m_Item3 = item3;
994 m_Item4 = item4;
995 m_Item5 = item5;
996 m_Item6 = item6;
997 m_Item7 = item7;
998 }
999
1000 public override bool Equals([NotNullWhen(true)] object? obj)
1001 {
1003 }
1004
1006 {
1007 return Equals(other, comparer);
1008 }
1009
1010 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
1011 {
1012 if (other == null)
1013 {
1014 return false;
1015 }
1017 {
1018 return false;
1019 }
1020 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2) && comparer.Equals(m_Item3, tuple.m_Item3) && comparer.Equals(m_Item4, tuple.m_Item4) && comparer.Equals(m_Item5, tuple.m_Item5) && comparer.Equals(m_Item6, tuple.m_Item6))
1021 {
1022 return comparer.Equals(m_Item7, tuple.m_Item7);
1023 }
1024 return false;
1025 }
1026
1028 {
1029 return ((IStructuralComparable)this).CompareTo(obj, (IComparer)Comparer<object>.Default);
1030 }
1031
1036
1037 private int CompareTo(object other, IComparer comparer)
1038 {
1039 if (other == null)
1040 {
1041 return 1;
1042 }
1044 {
1045 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
1046 }
1047 int num = comparer.Compare(m_Item1, tuple.m_Item1);
1048 if (num != 0)
1049 {
1050 return num;
1051 }
1052 num = comparer.Compare(m_Item2, tuple.m_Item2);
1053 if (num != 0)
1054 {
1055 return num;
1056 }
1057 num = comparer.Compare(m_Item3, tuple.m_Item3);
1058 if (num != 0)
1059 {
1060 return num;
1061 }
1062 num = comparer.Compare(m_Item4, tuple.m_Item4);
1063 if (num != 0)
1064 {
1065 return num;
1066 }
1067 num = comparer.Compare(m_Item5, tuple.m_Item5);
1068 if (num != 0)
1069 {
1070 return num;
1071 }
1072 num = comparer.Compare(m_Item6, tuple.m_Item6);
1073 if (num != 0)
1074 {
1075 return num;
1076 }
1077 return comparer.Compare(m_Item7, tuple.m_Item7);
1078 }
1079
1080 public override int GetHashCode()
1081 {
1083 }
1084
1089
1094
1096 {
1097 return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7));
1098 }
1099
1100 public override string ToString()
1101 {
1103 stringBuilder.Append('(');
1104 return ToString(stringBuilder);
1105 }
1106
1108 {
1109 return ToString(sb);
1110 }
1111
1112 private string ToString(StringBuilder sb)
1113 {
1114 sb.Append(m_Item1);
1115 sb.Append(", ");
1116 sb.Append(m_Item2);
1117 sb.Append(", ");
1118 sb.Append(m_Item3);
1119 sb.Append(", ");
1120 sb.Append(m_Item4);
1121 sb.Append(", ");
1122 sb.Append(m_Item5);
1123 sb.Append(", ");
1124 sb.Append(m_Item6);
1125 sb.Append(", ");
1126 sb.Append(m_Item7);
1127 sb.Append(')');
1128 return sb.ToString();
1129 }
1130}
1131[Serializable]
1132[TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")]
1133public class Tuple<T1, T2, T3, T4, T5, T6, T7, TRest> : IStructuralEquatable, IStructuralComparable, IComparable, ITupleInternal, ITuple where TRest : notnull
1134{
1135 private readonly T1 m_Item1;
1136
1137 private readonly T2 m_Item2;
1138
1139 private readonly T3 m_Item3;
1140
1141 private readonly T4 m_Item4;
1142
1143 private readonly T5 m_Item5;
1144
1145 private readonly T6 m_Item6;
1146
1147 private readonly T7 m_Item7;
1148
1149 private readonly TRest m_Rest;
1150
1151 public T1 Item1 => m_Item1;
1152
1153 public T2 Item2 => m_Item2;
1154
1155 public T3 Item3 => m_Item3;
1156
1157 public T4 Item4 => m_Item4;
1158
1159 public T5 Item5 => m_Item5;
1160
1161 public T6 Item6 => m_Item6;
1162
1163 public T7 Item7 => m_Item7;
1164
1165 public TRest Rest => m_Rest;
1166
1167 int ITuple.Length => 7 + ((ITupleInternal)(object)Rest).Length;
1168
1169 object? ITuple.this[int index] => index switch
1170 {
1171 0 => Item1,
1172 1 => Item2,
1173 2 => Item3,
1174 3 => Item4,
1175 4 => Item5,
1176 5 => Item6,
1177 6 => Item7,
1178 _ => ((ITupleInternal)(object)Rest)[index - 7],
1179 };
1180
1181 public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
1182 {
1183 if (!(rest is ITupleInternal))
1184 {
1186 }
1187 m_Item1 = item1;
1188 m_Item2 = item2;
1189 m_Item3 = item3;
1190 m_Item4 = item4;
1191 m_Item5 = item5;
1192 m_Item6 = item6;
1193 m_Item7 = item7;
1194 m_Rest = rest;
1195 }
1196
1197 public override bool Equals([NotNullWhen(true)] object? obj)
1198 {
1200 }
1201
1203 {
1204 return Equals(other, comparer);
1205 }
1206
1207 private bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
1208 {
1209 if (other == null)
1210 {
1211 return false;
1212 }
1214 {
1215 return false;
1216 }
1217 if (comparer.Equals(m_Item1, tuple.m_Item1) && comparer.Equals(m_Item2, tuple.m_Item2) && comparer.Equals(m_Item3, tuple.m_Item3) && comparer.Equals(m_Item4, tuple.m_Item4) && comparer.Equals(m_Item5, tuple.m_Item5) && comparer.Equals(m_Item6, tuple.m_Item6) && comparer.Equals(m_Item7, tuple.m_Item7))
1218 {
1219 return comparer.Equals(m_Rest, tuple.m_Rest);
1220 }
1221 return false;
1222 }
1223
1225 {
1227 }
1228
1233
1234 private int CompareTo(object other, IComparer comparer)
1235 {
1236 if (other == null)
1237 {
1238 return 1;
1239 }
1241 {
1242 throw new ArgumentException(SR.Format(SR.ArgumentException_TupleIncorrectType, GetType()), "other");
1243 }
1244 int num = comparer.Compare(m_Item1, tuple.m_Item1);
1245 if (num != 0)
1246 {
1247 return num;
1248 }
1249 num = comparer.Compare(m_Item2, tuple.m_Item2);
1250 if (num != 0)
1251 {
1252 return num;
1253 }
1254 num = comparer.Compare(m_Item3, tuple.m_Item3);
1255 if (num != 0)
1256 {
1257 return num;
1258 }
1259 num = comparer.Compare(m_Item4, tuple.m_Item4);
1260 if (num != 0)
1261 {
1262 return num;
1263 }
1264 num = comparer.Compare(m_Item5, tuple.m_Item5);
1265 if (num != 0)
1266 {
1267 return num;
1268 }
1269 num = comparer.Compare(m_Item6, tuple.m_Item6);
1270 if (num != 0)
1271 {
1272 return num;
1273 }
1274 num = comparer.Compare(m_Item7, tuple.m_Item7);
1275 if (num != 0)
1276 {
1277 return num;
1278 }
1279 return comparer.Compare(m_Rest, tuple.m_Rest);
1280 }
1281
1282 public override int GetHashCode()
1283 {
1285 }
1286
1291
1293 {
1295 if (tupleInternal.Length >= 8)
1296 {
1297 return tupleInternal.GetHashCode(comparer);
1298 }
1299 return (8 - tupleInternal.Length) switch
1300 {
1301 1 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1302 2 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1303 3 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1304 4 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1305 5 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1306 6 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1307 7 => Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7), tupleInternal.GetHashCode(comparer)),
1308 _ => -1,
1309 };
1310 }
1311
1316
1317 public override string ToString()
1318 {
1320 stringBuilder.Append('(');
1321 return ToString(stringBuilder);
1322 }
1323
1325 {
1326 return ToString(sb);
1327 }
1328
1329 private string ToString(StringBuilder sb)
1330 {
1331 sb.Append(m_Item1);
1332 sb.Append(", ");
1333 sb.Append(m_Item2);
1334 sb.Append(", ");
1335 sb.Append(m_Item3);
1336 sb.Append(", ");
1337 sb.Append(m_Item4);
1338 sb.Append(", ");
1339 sb.Append(m_Item5);
1340 sb.Append(", ");
1341 sb.Append(m_Item6);
1342 sb.Append(", ");
1343 sb.Append(m_Item7);
1344 sb.Append(", ");
1345 return ((ITupleInternal)(object)m_Rest).ToString(sb);
1346 }
1347}
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentException_TupleIncorrectType
Definition SR.cs:922
static string ArgumentException_TupleLastArgumentNotATuple
Definition SR.cs:924
Definition SR.cs:7
override string ToString()
StringBuilder Append(char value, int repeatCount)
static Tuple< T1, T2, T3, T4 > Create< T1, T2, T3, T4 >(T1 item1, T2 item2, T3 item3, T4 item4)
Definition Tuple.cs:26
readonly T6 m_Item6
Definition Tuple.cs:782
readonly T3 m_Item3
Definition Tuple.cs:329
Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
Definition Tuple.cs:642
static Tuple< T1, T2, T3 > Create< T1, T2, T3 >(T1 item1, T2 item2, T3 item3)
Definition Tuple.cs:21
override string ToString()
Definition Tuple.cs:179
int IComparable. CompareTo(object obj)
Definition Tuple.cs:136
Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
Definition Tuple.cs:989
static Tuple< T1, T2, T3, T4, T5 > Create< T1, T2, T3, T4, T5 >(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5)
Definition Tuple.cs:31
Tuple(T1 item1, T2 item2)
Definition Tuple.cs:219
static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5)
Definition Tuple.cs:66
Tuple(T1 item1)
Definition Tuple.cs:108
string ToString(StringBuilder sb)
Definition Tuple.cs:191
Tuple(T1 item1, T2 item2, T3 item3)
Definition Tuple.cs:347
readonly T7 m_Item7
Definition Tuple.cs:959
override int GetHashCode()
Definition Tuple.cs:159
override bool Equals([NotNullWhen(true)] object? obj)
Definition Tuple.cs:113
static int CombineHashCodes(int h1, int h2, int h3, int h4)
Definition Tuple.cs:61
readonly T4 m_Item4
Definition Tuple.cs:467
static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7)
Definition Tuple.cs:76
int ITuple. Length
Definition Tuple.cs:94
static Tuple< T1, T2, T3, T4, T5, T6, T7, Tuple< T8 > > Create< T1, T2, T3, T4, T5, T6, T7, T8 >(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8)
Definition Tuple.cs:46
int CompareTo(object other, IComparer comparer)
Definition Tuple.cs:146
static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8)
Definition Tuple.cs:81
readonly T5 m_Item5
Definition Tuple.cs:618
bool Equals([NotNullWhen(true)] object other, IEqualityComparer comparer)
Definition Tuple.cs:123
int GetHashCode(IEqualityComparer comparer)
Definition Tuple.cs:174
static Tuple< T1 > Create< T1 >(T1 item1)
Definition Tuple.cs:11
static Tuple< T1, T2, T3, T4, T5, T6 > Create< T1, T2, T3, T4, T5, T6 >(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
Definition Tuple.cs:36
static int CombineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6)
Definition Tuple.cs:71
static int CombineHashCodes(int h1, int h2)
Definition Tuple.cs:51
readonly T1 m_Item1
Definition Tuple.cs:90
static Tuple< T1, T2 > Create< T1, T2 >(T1 item1, T2 item2)
Definition Tuple.cs:16
Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6)
Definition Tuple.cs:809
Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
Definition Tuple.cs:1181
static Tuple< T1, T2, T3, T4, T5, T6, T7 > Create< T1, T2, T3, T4, T5, T6, T7 >(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7)
Definition Tuple.cs:41
Tuple(T1 item1, T2 item2, T3 item3, T4 item4)
Definition Tuple.cs:488
readonly T2 m_Item2
Definition Tuple.cs:204
TRest Rest
Definition Tuple.cs:1165
readonly TRest m_Rest
Definition Tuple.cs:1149
static int CombineHashCodes(int h1, int h2, int h3)
Definition Tuple.cs:56
int CompareTo(object? other, IComparer comparer)
int GetHashCode(IEqualityComparer comparer)
bool Equals(object? other, IEqualityComparer comparer)
int CompareTo(object? obj)
int GetHashCode(IEqualityComparer comparer)
string ToString(StringBuilder sb)