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 Interop.ItemIdContainer.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 /// <since_tizen> 3 </since_tizen>
221 public sealed class ItemIdContainerEnumerator : global::System.Collections.IEnumerator
222 , global::System.Collections.Generic.IEnumerator<uint>
224 private ItemIdContainer collectionRef;
225 private int currentIndex;
226 private object currentObject;
227 private int currentSize;
229 /// <since_tizen> 3 </since_tizen>
230 public ItemIdContainerEnumerator(ItemIdContainer collection)
232 collectionRef = collection;
234 currentObject = null;
235 currentSize = collectionRef.Count;
238 // Type-safe iterator Current
239 /// <since_tizen> 3 </since_tizen>
244 if (currentIndex == -1)
245 throw new global::System.InvalidOperationException("Enumeration not started.");
246 if (currentIndex > currentSize - 1)
247 throw new global::System.InvalidOperationException("Enumeration finished.");
248 if (currentObject == null)
249 throw new global::System.InvalidOperationException("Collection modified.");
250 return (uint)currentObject;
254 // Type-unsafe IEnumerator.Current
255 object global::System.Collections.IEnumerator.Current
263 /// <since_tizen> 3 </since_tizen>
264 public bool MoveNext()
266 int size = collectionRef.Count;
267 bool moveOkay = (currentIndex + 1 < size) && (size == currentSize);
271 currentObject = collectionRef[currentIndex];
275 currentObject = null;
280 /// <since_tizen> 3 </since_tizen>
284 currentObject = null;
285 if (collectionRef.Count != currentSize)
287 throw new global::System.InvalidOperationException("Collection modified.");
291 /// <since_tizen> 3 </since_tizen>
292 public void Dispose()
295 currentObject = null;
301 Interop.ItemIdContainer.ItemIdContainer_Clear(swigCPtr);
302 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
305 public void Add(uint x)
307 Interop.ItemIdContainer.ItemIdContainer_Add(swigCPtr, x);
308 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
313 uint ret = Interop.ItemIdContainer.ItemIdContainer_size(swigCPtr);
314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
318 private uint capacity()
320 uint ret = Interop.ItemIdContainer.ItemIdContainer_capacity(swigCPtr);
321 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
325 private void reserve(uint n)
327 Interop.ItemIdContainer.ItemIdContainer_reserve(swigCPtr, n);
328 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
331 public ItemIdContainer() : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_0(), true)
333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
336 public ItemIdContainer(ItemIdContainer other) : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_1(ItemIdContainer.getCPtr(other)), true)
338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341 public ItemIdContainer(int capacity) : this(Interop.ItemIdContainer.new_ItemIdContainer__SWIG_2(capacity), true)
343 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
346 private uint getitemcopy(int index)
348 uint ret = Interop.ItemIdContainer.ItemIdContainer_getitemcopy(swigCPtr, index);
349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
353 private uint getitem(int index)
355 uint ret = Interop.ItemIdContainer.ItemIdContainer_getitem(swigCPtr, index);
356 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
360 private void setitem(int index, uint val)
362 Interop.ItemIdContainer.ItemIdContainer_setitem(swigCPtr, index, val);
363 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
366 public void AddRange(ItemIdContainer values)
368 Interop.ItemIdContainer.ItemIdContainer_AddRange(swigCPtr, ItemIdContainer.getCPtr(values));
369 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
372 public ItemIdContainer GetRange(int index, int count)
374 global::System.IntPtr cPtr = Interop.ItemIdContainer.ItemIdContainer_GetRange(swigCPtr, index, count);
375 ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
380 public void Insert(int index, uint x)
382 Interop.ItemIdContainer.ItemIdContainer_Insert(swigCPtr, index, x);
383 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
386 public void InsertRange(int index, ItemIdContainer values)
388 Interop.ItemIdContainer.ItemIdContainer_InsertRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 public void RemoveAt(int index)
394 Interop.ItemIdContainer.ItemIdContainer_RemoveAt(swigCPtr, index);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398 public void RemoveRange(int index, int count)
400 Interop.ItemIdContainer.ItemIdContainer_RemoveRange(swigCPtr, index, count);
401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
404 public static ItemIdContainer Repeat(uint value, int count)
406 global::System.IntPtr cPtr = Interop.ItemIdContainer.ItemIdContainer_Repeat(value, count);
407 ItemIdContainer ret = (cPtr == global::System.IntPtr.Zero) ? null : new ItemIdContainer(cPtr, true);
408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 public void Reverse()
414 Interop.ItemIdContainer.ItemIdContainer_Reverse__SWIG_0(swigCPtr);
415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
418 public void Reverse(int index, int count)
420 Interop.ItemIdContainer.ItemIdContainer_Reverse__SWIG_1(swigCPtr, index, count);
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 public void SetRange(int index, ItemIdContainer values)
426 Interop.ItemIdContainer.ItemIdContainer_SetRange(swigCPtr, index, ItemIdContainer.getCPtr(values));
427 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
430 public bool Contains(uint value)
432 bool ret = Interop.ItemIdContainer.ItemIdContainer_Contains(swigCPtr, value);
433 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
437 public int IndexOf(uint value)
439 int ret = Interop.ItemIdContainer.ItemIdContainer_IndexOf(swigCPtr, value);
440 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 public int LastIndexOf(uint value)
446 int ret = Interop.ItemIdContainer.ItemIdContainer_LastIndexOf(swigCPtr, value);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 public bool Remove(uint value)
453 bool ret = Interop.ItemIdContainer.ItemIdContainer_Remove(swigCPtr, value);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();