forked from laicasaane/unity-supplements
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayList{T}.Collection.cs
More file actions
89 lines (68 loc) · 2.4 KB
/
Copy pathArrayList{T}.Collection.cs
File metadata and controls
89 lines (68 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System.Collections.Generic;
namespace System.Collections.ArrayBased
{
public partial class ArrayList<T>
{
public Collection AsCollection()
=> new Collection(this);
public static explicit operator Collection(ArrayList<T> source)
=> new Collection(source);
public readonly struct Collection : ICollection<T>, IReadOnlyCollection<T>
{
private readonly ArrayList<T> source;
public Collection(ArrayList<T> source)
{
this.source = source ?? throw new ArgumentNullException(nameof(source));
}
public int Count
{
get
{
unchecked
{
return (int)this.source.count;
}
}
}
public bool IsReadOnly => false;
public void Add(T item)
=> this.source.Add(item);
public void Clear()
=> this.source.Clear();
public bool Contains(T item)
=> this.source.Contains(item);
public void CopyTo(T[] array, int arrayIndex)
=> this.source.CopyTo(array, arrayIndex);
public bool Remove(T item)
=> this.source.Remove(item);
public Enumerator GetEnumerator()
=> new Enumerator(this.source);
IEnumerator<T> IEnumerable<T>.GetEnumerator()
=> GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public struct Enumerator : IEnumerator<T>
{
private readonly ArrayList<T>.Enumerator source;
public Enumerator(ArrayList<T> source)
{
this.source = (source ?? Empty).GetEnumerator();
}
public T Current
{
get => this.source.Current;
}
object IEnumerator.Current
{
get => this.Current;
}
public void Dispose()
=> this.source.Dispose();
public bool MoveNext()
=> this.source.MoveNext();
public void Reset()
=> this.source.Reset();
}
}
}
}