Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ListChunk.cs
Go to the documentation of this file.
3
5
6internal sealed class ListChunk<TInputOutput> : IEnumerable<TInputOutput>, IEnumerable
7{
8 internal TInputOutput[] _chunk;
9
10 private int _chunkCount;
11
13
15
17
18 internal int Count => _chunkCount;
19
20 internal ListChunk(int size)
21 {
23 _chunkCount = 0;
24 _tailChunk = this;
25 }
26
27 internal void Add(TInputOutput e)
28 {
30 if (listChunk._chunkCount == listChunk._chunk.Length)
31 {
32 _tailChunk = new ListChunk<TInputOutput>(listChunk._chunkCount * 2);
33 listChunk = (listChunk._nextChunk = _tailChunk);
34 }
35 listChunk._chunk[listChunk._chunkCount++] = e;
36 }
37
39 {
40 for (ListChunk<TInputOutput> curr = this; curr != null; curr = curr._nextChunk)
41 {
42 for (int i = 0; i < curr._chunkCount; i++)
43 {
44 yield return curr._chunk[i];
45 }
46 }
47 }
48
53}
ListChunk< TInputOutput > _tailChunk
Definition ListChunk.cs:14
IEnumerator< TInputOutput > GetEnumerator()
Definition ListChunk.cs:38
void Add(TInputOutput e)
Definition ListChunk.cs:27
ListChunk< TInputOutput > Next
Definition ListChunk.cs:16
ListChunk< TInputOutput > _nextChunk
Definition ListChunk.cs:12
new IEnumerator< T > GetEnumerator()