-
Notifications
You must be signed in to change notification settings - Fork 936
/
Copy pathSetSnapShot.cs
109 lines (90 loc) · 1.8 KB
/
SetSnapShot.cs
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections;
using System.Collections.Generic;
namespace NHibernate.Collection.Generic.SetHelpers
{
[Serializable]
internal class SetSnapShot<T> : ISetSnapshot<T>
{
private readonly List<T> _elements;
public SetSnapShot()
{
_elements = new List<T>();
}
public SetSnapShot(int capacity)
{
_elements = new List<T>(capacity);
}
public SetSnapShot(IEnumerable<T> collection)
{
_elements = new List<T>(collection);
}
public IEnumerator<T> GetEnumerator()
{
return _elements.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Add(T item)
{
_elements.Add(item);
}
public void Clear()
{
throw new InvalidOperationException();
}
public bool Contains(T item)
{
return _elements.Contains(item);
}
public void CopyTo(T[] array, int arrayIndex)
{
_elements.CopyTo(array, arrayIndex);
}
public bool Remove(T item)
{
throw new InvalidOperationException();
}
public void CopyTo(Array array, int index)
{
((ICollection)_elements).CopyTo(array, index);
}
int ICollection.Count
{
get { return _elements.Count; }
}
public object SyncRoot
{
get { return ((ICollection)_elements).SyncRoot; }
}
public bool IsSynchronized
{
get { return ((ICollection)_elements).IsSynchronized; }
}
int ICollection<T>.Count
{
get { return _elements.Count; }
}
int IReadOnlyCollection<T>.Count
{
get { return _elements.Count; }
}
public bool IsReadOnly
{
get { return ((ICollection<T>)_elements).IsReadOnly; }
}
public bool TryGetValue(T element, out T value)
{
var idx = _elements.IndexOf(element);
if (idx >= 0)
{
value = _elements[idx];
return true;
}
value = default(T);
return false;
}
}
}