Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Grouping.cs
Go to the documentation of this file.
4
5namespace System.Linq;
6
7[DebuggerDisplay("Key = {Key}")]
9public class Grouping<TKey, TElement> : IGrouping<TKey, TElement>, IEnumerable<TElement>, IEnumerable, IList<TElement>, ICollection<TElement>
10{
11 internal readonly TKey _key;
12
13 internal readonly int _hashCode;
14
15 internal TElement[] _elements;
16
17 internal int _count;
18
20
22
23 public TKey Key => _key;
24
26
28
29 TElement IList<TElement>.this[int index]
30 {
31 get
32 {
34 {
36 }
37 return _elements[index];
38 }
39 set
40 {
42 }
43 }
44
45 internal Grouping(TKey key, int hashCode)
46 {
47 _key = key;
48 _hashCode = hashCode;
49 _elements = new TElement[1];
50 }
51
52 internal void Add(TElement element)
53 {
54 if (_elements.Length == _count)
55 {
56 Array.Resize(ref _elements, checked(_count * 2));
57 }
58 _elements[_count] = element;
59 _count++;
60 }
61
62 internal void Trim()
63 {
64 if (_elements.Length != _count)
65 {
66 Array.Resize(ref _elements, _count);
67 }
68 }
69
71 {
72 for (int i = 0; i < _count; i++)
73 {
74 yield return _elements[i];
75 }
76 }
77
82
87
92
94 {
95 return Array.IndexOf(_elements, item, 0, _count) >= 0;
96 }
97
99 {
101 }
102
104 {
106 return false;
107 }
108
109 int IList<TElement>.IndexOf(TElement item)
110 {
111 return Array.IndexOf(_elements, item, 0, _count);
112 }
113
114 void IList<TElement>.Insert(int index, TElement item)
115 {
117 }
118
119 void IList<TElement>.RemoveAt(int index)
120 {
122 }
123}
int IList. IndexOf(object value)
Definition Array.cs:1228
static unsafe void Copy(Array sourceArray, Array destinationArray, int length)
Definition Array.cs:624
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void CopyTo(KeyValuePair< TKey, TValue >[] array, int index)
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
readonly TKey _key
Definition Grouping.cs:11
readonly int _hashCode
Definition Grouping.cs:13
Grouping(TKey key, int hashCode)
Definition Grouping.cs:45
Grouping< TKey, TElement > _next
Definition Grouping.cs:21
Grouping< TKey, TElement > _hashNext
Definition Grouping.cs:19
TElement[] _elements
Definition Grouping.cs:15
void Add(TElement element)
Definition Grouping.cs:52
IEnumerator< TElement > GetEnumerator()
Definition Grouping.cs:70
static void ThrowArgumentOutOfRangeException(ExceptionArgument argument)
static void ThrowNotSupportedException()
new IEnumerator< T > GetEnumerator()