Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CollectionExtensions.cs
Go to the documentation of this file.
3using System.Linq;
5
7
8internal static class CollectionExtensions
9{
11 {
12 T[] array = new T[list.Count + 1];
13 array[0] = item;
14 list.CopyTo(array, 1);
16 }
17
18 public static T[] AddFirst<T>(this T[] array, T item)
19 {
20 T[] array2 = new T[array.Length + 1];
21 array2[0] = item;
23 return array2;
24 }
25
26 public static T[] AddLast<T>(this T[] array, T item)
27 {
28 T[] array2 = new T[array.Length + 1];
30 array2[array.Length] = item;
31 return array2;
32 }
33
34 public static T[] RemoveFirst<T>(this T[] array)
35 {
36 T[] array2 = new T[array.Length - 1];
37 Array.Copy(array, 1, array2, 0, array2.Length);
38 return array2;
39 }
40
41 public static T[] RemoveLast<T>(this T[] array)
42 {
43 T[] array2 = new T[array.Length - 1];
44 Array.Copy(array, array2, array2.Length);
45 return array2;
46 }
47
49 {
50 if (enumerable == null)
51 {
52 return EmptyReadOnlyCollection<T>.Instance;
53 }
55 {
56 return result;
57 }
59 {
60 return readOnlyCollectionBuilder.ToReadOnlyCollection();
61 }
62 T[] array = enumerable.ToArray();
63 if (array.Length != 0)
64 {
66 }
67 return EmptyReadOnlyCollection<T>.Instance;
68 }
69
71 {
73 int num = 6551;
74 foreach (T item in list)
75 {
76 if (item != null)
77 {
78 num ^= (num << 5) ^ @default.GetHashCode(item);
79 }
80 }
81 return num;
82 }
83
85 {
86 if (first == second)
87 {
88 return true;
89 }
90 int count = first.Count;
91 if (count != second.Count)
92 {
93 return false;
94 }
96 for (int i = 0; i != count; i++)
97 {
98 if (!@default.Equals(first[i], second[i]))
99 {
100 return false;
101 }
102 }
103 return true;
104 }
105}
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
static ReadOnlyCollection< T > ToReadOnly< T >(this IEnumerable< T > enumerable)
static T[] AddLast< T >(this T[] array, T item)
static TrueReadOnlyCollection< T > AddFirst< T >(this ReadOnlyCollection< T > list, T item)
static bool ListEquals< T >(this ReadOnlyCollection< T > first, ReadOnlyCollection< T > second)
static int ListHashCode< T >(this ReadOnlyCollection< T > list)