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);
52 bool ICollection<T>.IsReadOnly
57 public bool Remove(T item)
61 if (_list.Remove(item))
71 IEnumerator IEnumerable.GetEnumerator()
73 return GetEnumerator();
76 public IEnumerator<T> GetEnumerator()
78 ReadOnlyCollection<T> snap = _snapshot;
82 _snapshot = snap = new ReadOnlyCollection<T>(_list.ToList());
85 return snap?.GetEnumerator();
88 public int IndexOf(T item)
91 return _list.IndexOf(item);
94 public void Insert(int index, T item)
98 _list.Insert(index, item);
103 public T this[int index]
109 ReadOnlyCollection<T> snap = _snapshot;
121 _list[index] = value;
127 public void RemoveAt(int index)
131 _list.RemoveAt(index);