Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
KeysOrValuesCollectionAccessor.cs
Go to the documentation of this file.
3
5
6internal abstract class KeysOrValuesCollectionAccessor<TKey, TValue, T> : ICollection<T>, IEnumerable<T>, IEnumerable, ICollection where TKey : notnull
7{
9
10 private readonly IEnumerable<T> _keysOrValues;
11
12 public bool IsReadOnly => true;
13
14 public int Count => _dictionary.Count;
15
17
20
22 object ICollection.SyncRoot => this;
23
31
32 public void Add(T item)
33 {
34 throw new NotSupportedException();
35 }
36
37 public void Clear()
38 {
39 throw new NotSupportedException();
40 }
41
42 public abstract bool Contains(T item);
43
44 public void CopyTo(T[] array, int arrayIndex)
45 {
46 Requires.NotNull(array, "array");
47 Requires.Range(arrayIndex >= 0, "arrayIndex");
48 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
50 while (enumerator.MoveNext())
51 {
52 T current = enumerator.Current;
53 array[arrayIndex++] = current;
54 }
55 }
56
57 public bool Remove(T item)
58 {
59 throw new NotSupportedException();
60 }
61
66
71
73 {
74 Requires.NotNull(array, "array");
75 Requires.Range(arrayIndex >= 0, "arrayIndex");
76 Requires.Range(array.Length >= arrayIndex + Count, "arrayIndex");
78 while (enumerator.MoveNext())
79 {
80 T current = enumerator.Current;
81 array.SetValue(current, arrayIndex++);
82 }
83 }
84}
KeysOrValuesCollectionAccessor(IImmutableDictionary< TKey, TValue > dictionary, IEnumerable< T > keysOrValues)
static void Range(bool condition, string? parameterName, string? message=null)
Definition Requires.cs:40
new IEnumerator< T > GetEnumerator()
void CopyTo(Array array, int index)