2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 internal class ItemIdContainer : global::System.IDisposable, global::System.Collections.IEnumerable
22 , global::System.Collections.Generic.IList<uint>
24 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
25 protected bool swigCMemOwn;
27 internal ItemIdContainer(global::System.IntPtr cPtr, bool cMemoryOwn)
29 swigCMemOwn = cMemoryOwn;
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ItemIdContainer obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 //A Flag to check who called Dispose(). (By User or DisposeQueue)
39 private bool isDisposeQueued = false;
40 //A Flat to check if it is already disposed.
41 protected bool disposed = false;
48 isDisposeQueued = true;
49 DisposeQueue.Instance.Add(this);
55 //Throw excpetion if Dispose() is called in separate thread.
56 if (!Window.IsInstalled())
58 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
63 Dispose(DisposeTypes.Implicit);
67 Dispose(DisposeTypes.Explicit);
68 System.GC.SuppressFinalize(this);
72 protected virtual void Dispose(DisposeTypes type)
79 if (type == DisposeTypes.Explicit)
82 //Release your own managed resources here.
83 //You should release all of your own disposable objects here.
87 //Release your own unmanaged resources here.
88 //You should not access any managed member here except static instance.
89 //because the execution order of Finalizes is non-deterministic.
91 if (swigCPtr.Handle != global::System.IntPtr.Zero)
96 NDalicPINVOKE.delete_ItemIdContainer(swigCPtr);
98 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
104 public ItemIdContainer(global::System.Collections.ICollection c) : this()
107 throw new global::System.ArgumentNullException("c");
108 foreach (uint element in c)
114 public bool IsFixedSize
122 public bool IsReadOnly
130 public uint this[int index]
134 return getitem(index);
138 setitem(index, value);
146 return (int)capacity();
151 throw new global::System.ArgumentOutOfRangeException("Capacity");
152 reserve((uint)value);
164 public bool IsSynchronized
172 public void CopyTo(uint[] array)
174 CopyTo(0, array, 0, this.Count);
177 public void CopyTo(uint[] array, int arrayIndex)
179 CopyTo(0, array, arrayIndex, this.Count);
182 public void CopyTo(int index, uint[] array, int arrayIndex, int count)
185 throw new global::System.ArgumentNullException("array");
187 throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
189 throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
191 throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
193 throw new global::System.ArgumentException("Multi dimensional array.", "array");
194 if (index + count > this.Count || arrayIndex + count > array.Length)
195 throw new global::System.ArgumentException("Number of elements to copy is too large.");
196 for (int i = 0; i < count; i++)
197 array.SetValue(getitemcopy(index + i), arrayIndex + i);
200 global::System.Collections.Generic.IEnumerator<uint> global::System.Collections.Generic.IEnumerable<uint>.GetEnumerator()
202 return new ItemIdContainerEnumerator(this);
205 global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
207 return new ItemIdContainerEnumerator(this);
210 public ItemIdContainerEnumerator GetEnumerator()
212 return new ItemIdContainerEnumerator(this);
215 // The type-safe enumerator.
216 /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
217 /// whenever the collection is modified. This has been done for changes in the size of the
218 /// collection, but not when one of the elements of the collection is modified as it is a bit
219 /// tricky to detect unmanaged code that modifies the collection under our feet.
220 public sealed class ItemIdContainerEnumerator : global::System.Collections.IEnumerator
221 , global::System.Collections.Generic.IEnumerator<uint>
223 private ItemIdContainer collectionRef;
224 private int currentIndex;
225 private object currentObject;
226 private int currentSize;
228 public ItemIdContainerEnumerator(ItemIdContainer collection)
230 collectionRef = collection;
232 currentObject = null;
233 currentSize = collectionRef.Count;
236 // Type-safe iterator Current
241 if (currentIndex == -1)
242 throw new global::System.InvalidOperationException("Enumeration not started.");
243 if (currentIndex > currentSize - 1)
244 throw new global::System.InvalidOperationException("Enumeration finished.");
245 if (currentObject == null)
246 throw new global::System.InvalidOperationException("Collection modified.");
247 return (uint)currentObject;
251 // Type-unsafe IEnumerator.Current
252 object global::System.Collections.IEnumerator.Current
260 public bool MoveNext()
262 int size = collectionRef.Count;
263 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
267 currentObject = collectionRef[currentIndex];
271 currentObject = null;
279 currentObject = null;
280 if (collectionRef.Count != currentSize)
282 throw new global::System.InvalidOperationException("Collection modified.");
286 public void Dispose()
289 currentObject = null;
295 NDalicPINVOKE.ItemIdContainer_Clear(swigCPtr);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
299 public void Add(uint x)
301 NDalicPINVOKE.ItemIdContainer_Add(swigCPtr, x);
302 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 uint ret = NDalicPINVOKE.ItemIdContainer_size(swigCPtr);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
312 private uint capacity()
314 uint ret = NDalicPINVOKE.ItemIdContainer_capacity(swigCPtr);
315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
319 private void reserve(uint n)
321 NDalicPINVOKE.ItemIdContainer_reserve(swigCPtr, n);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 public ItemIdContainer() : this(NDalicPINVOKE.new_ItemIdContainer__SWIG_0(), true)
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 public ItemIdContainer(ItemIdContainer other) : this(NDalicPINVOKE.new_ItemIdContainer__SWIG_1(ItemIdContainer.getCPtr(other)), true)
332 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335 public ItemIdContainer(int capacity) : this(NDalicPINVOKE.new_ItemIdContainer__SWIG_2(capacity), true)
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
340 private uint getitemcopy(int index)
342 uint ret = NDalicPINVOKE.ItemIdContainer_getitemcopy(swigCPtr, index);
343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
347 private uint getitem(int index)
349 uint ret = NDalicPINVOKE.ItemIdContainer_getitem(swigCPtr, index);
350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354 private void setitem(int index, uint val)
356 NDalicPINVOKE.ItemIdContainer_setitem(swigCPtr, index, val);
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360 public void AddRange(ItemIdContainer values)
362 NDalicPINVOKE.ItemIdContainer_AddRange(swigCPtr, ItemIdContainer.getCPtr(values));
363 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 public ItemIdContainer GetRange(int index, int count)
368 global::System.IntPtr cPtr = NDalicPINVOKE.ItemIdContainer_GetRange(swigCPtr, index, count);
369 ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
370 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 public void Insert(int index, uint x)
376 NDalicPINVOKE.ItemIdContainer_Insert(swigCPtr, index, x);
377 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 public void InsertRange(int index, ItemIdContainer values)
382 NDalicPINVOKE.ItemIdContainer_InsertRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 public void RemoveAt(int index)
388 NDalicPINVOKE.ItemIdContainer_RemoveAt(swigCPtr, index);
389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 public void RemoveRange(int index, int count)
394 NDalicPINVOKE.ItemIdContainer_RemoveRange(swigCPtr, index, count);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 public static ItemIdContainer Repeat(uint value, int count)
400 global::System.IntPtr cPtr = NDalicPINVOKE.ItemIdContainer_Repeat(value, count);
401 ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
402 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 public void Reverse()
408 NDalicPINVOKE.ItemIdContainer_Reverse__SWIG_0(swigCPtr);
409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 public void Reverse(int index, int count)
414 NDalicPINVOKE.ItemIdContainer_Reverse__SWIG_1(swigCPtr, index, count);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 public void SetRange(int index, ItemIdContainer values)
420 NDalicPINVOKE.ItemIdContainer_SetRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 public bool Contains(uint value)
426 bool ret = NDalicPINVOKE.ItemIdContainer_Contains(swigCPtr, value);
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
431 public int IndexOf(uint value)
433 int ret = NDalicPINVOKE.ItemIdContainer_IndexOf(swigCPtr, value);
434 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438 public int LastIndexOf(uint value)
440 int ret = NDalicPINVOKE.ItemIdContainer_LastIndexOf(swigCPtr, value);
441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
445 public bool Remove(uint value)
447 bool ret = NDalicPINVOKE.ItemIdContainer_Remove(swigCPtr, value);
448 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();