1 using System.Collections;
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
6 namespace Tizen.NUI.Binding
8 internal class SynchronizedList<T> : IList<T>, IReadOnlyList<T>
10 readonly List<T> _list = new List<T>();
11 ReadOnlyCollection<T> _snapshot;
13 public void Add(T item)
31 public bool Contains(T item)
34 return _list.Contains(item);
37 public void CopyTo(T[] array, int arrayIndex)
40 _list.CopyTo(array, arrayIndex);
45 get { return _list.Count; }
48 bool ICollection<T>.IsReadOnly
53 public bool Remove(T item)
57 if (_list.Remove(item))
67 IEnumerator IEnumerable.GetEnumerator()
69 return GetEnumerator();
72 public IEnumerator<T> GetEnumerator()
74 ReadOnlyCollection<T> snap = _snapshot;
78 _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
81 return snap.GetEnumerator();
84 public int IndexOf(T item)
87 return _list.IndexOf(item);
90 public void Insert(int index, T item)
94 _list.Insert(index, item);
99 public T this[int index]
103 ReadOnlyCollection<T> snap = _snapshot;
115 _list[index] = value;
121 public void RemoveAt(int index)
125 _list.RemoveAt(index);