Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
IntVector.cs
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// <auto-generated />
3//
4// This file was automatically generated by SWIG (https://www.swig.org).
5// Version 4.2.1
6//
7// Do not make changes to this file unless you know what you are doing - modify
8// the SWIG interface file instead.
9//------------------------------------------------------------------------------
10
12
13public class IntVector : global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IList<int>
14 {
15 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
16 protected bool swigCMemOwn;
17
18 internal IntVector(global::System.IntPtr cPtr, bool cMemoryOwn) {
19 swigCMemOwn = cMemoryOwn;
20 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
21 }
22
23 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(IntVector obj) {
24 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
25 }
26
27 internal static global::System.Runtime.InteropServices.HandleRef swigRelease(IntVector obj) {
28 if (obj != null) {
29 if (!obj.swigCMemOwn)
30 throw new global::System.ApplicationException("Cannot release ownership as memory is not owned");
31 global::System.Runtime.InteropServices.HandleRef ptr = obj.swigCPtr;
32 obj.swigCMemOwn = false;
33 obj.Dispose();
34 return ptr;
35 } else {
36 return new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
37 }
38 }
39
40 ~IntVector() {
41 Dispose(false);
42 }
43
44 public void Dispose() {
45 Dispose(true);
46 global::System.GC.SuppressFinalize(this);
47 }
48
49 protected virtual void Dispose(bool disposing) {
50 lock(this) {
51 if (swigCPtr.Handle != global::System.IntPtr.Zero) {
52 if (swigCMemOwn) {
53 swigCMemOwn = false;
55 }
56 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
57 }
58 }
59 }
60
61 public IntVector(global::System.Collections.IEnumerable c) : this() {
62 if (c == null)
63 throw new global::System.ArgumentNullException("c");
64 foreach (int element in c) {
65 this.Add(element);
66 }
67 }
68
69 public IntVector(global::System.Collections.Generic.IEnumerable<int> c) : this() {
70 if (c == null)
71 throw new global::System.ArgumentNullException("c");
72 foreach (int element in c) {
73 this.Add(element);
74 }
75 }
76
77 public bool IsFixedSize {
78 get {
79 return false;
80 }
81 }
82
83 public bool IsReadOnly {
84 get {
85 return false;
86 }
87 }
88
89 public int this[int index] {
90 get {
91 return getitem(index);
92 }
93 set {
94 setitem(index, value);
95 }
96 }
97
98 public int Capacity {
99 get {
100 return (int)capacity();
101 }
102 set {
103 if (value < 0 || (uint)value < size())
104 throw new global::System.ArgumentOutOfRangeException("Capacity");
105 reserve((uint)value);
106 }
107 }
108
109 public bool IsEmpty {
110 get {
111 return empty();
112 }
113 }
114
115 public int Count {
116 get {
117 return (int)size();
118 }
119 }
120
121 public bool IsSynchronized {
122 get {
123 return false;
124 }
125 }
126
127 public void CopyTo(int[] array)
128 {
129 CopyTo(0, array, 0, this.Count);
130 }
131
132 public void CopyTo(int[] array, int arrayIndex)
133 {
134 CopyTo(0, array, arrayIndex, this.Count);
135 }
136
137 public void CopyTo(int index, int[] array, int arrayIndex, int count)
138 {
139 if (array == null)
140 throw new global::System.ArgumentNullException("array");
141 if (index < 0)
142 throw new global::System.ArgumentOutOfRangeException("index", "Value is less than zero");
143 if (arrayIndex < 0)
144 throw new global::System.ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
145 if (count < 0)
146 throw new global::System.ArgumentOutOfRangeException("count", "Value is less than zero");
147 if (array.Rank > 1)
148 throw new global::System.ArgumentException("Multi dimensional array.", "array");
149 if (index+count > this.Count || arrayIndex+count > array.Length)
150 throw new global::System.ArgumentException("Number of elements to copy is too large.");
151 for (int i=0; i<count; i++)
152 array.SetValue(getitemcopy(index+i), arrayIndex+i);
153 }
154
155 public int[] ToArray() {
156 int[] array = new int[this.Count];
157 this.CopyTo(array);
158 return array;
159 }
160
161 global::System.Collections.Generic.IEnumerator<int> global::System.Collections.Generic.IEnumerable<int>.GetEnumerator() {
162 return new IntVectorEnumerator(this);
163 }
164
165 global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
166 return new IntVectorEnumerator(this);
167 }
168
169 public IntVectorEnumerator GetEnumerator() {
170 return new IntVectorEnumerator(this);
172
173 // Type-safe enumerator
178 public sealed class IntVectorEnumerator : global::System.Collections.IEnumerator
179 , global::System.Collections.Generic.IEnumerator<int>
181 private IntVector collectionRef;
182 private int currentIndex;
183 private object currentObject;
184 private int currentSize;
185
186 public IntVectorEnumerator(IntVector collection) {
187 collectionRef = collection;
188 currentIndex = -1;
189 currentObject = null;
190 currentSize = collectionRef.Count;
191 }
192
193 // Type-safe iterator Current
194 public int Current {
195 get {
196 if (currentIndex == -1)
197 throw new global::System.InvalidOperationException("Enumeration not started.");
198 if (currentIndex > currentSize - 1)
199 throw new global::System.InvalidOperationException("Enumeration finished.");
200 if (currentObject == null)
201 throw new global::System.InvalidOperationException("Collection modified.");
202 return (int)currentObject;
203 }
204 }
205
206 // Type-unsafe IEnumerator.Current
207 object global::System.Collections.IEnumerator.Current {
208 get {
209 return Current;
210 }
211 }
212
213 public bool MoveNext() {
214 int size = collectionRef.Count;
215 bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
216 if (moveOkay) {
217 currentIndex++;
218 currentObject = collectionRef[currentIndex];
219 } else {
220 currentObject = null;
221 }
222 return moveOkay;
223 }
224
225 public void Reset() {
226 currentIndex = -1;
227 currentObject = null;
228 if (collectionRef.Count != currentSize) {
229 throw new global::System.InvalidOperationException("Collection modified.");
230 }
231 }
232
233 public void Dispose() {
234 currentIndex = -1;
235 currentObject = null;
236 }
237 }
238
239 public IntVector() : this(operations_research_model_builderPINVOKE.new_IntVector__SWIG_0(), true) {
240 }
242 public IntVector(IntVector other) : this(operations_research_model_builderPINVOKE.new_IntVector__SWIG_1(IntVector.getCPtr(other)), true) {
245
246 public void Clear() {
249
250 public void Add(int x) {
253
254 private uint size() {
256 return ret;
257 }
258
259 private bool empty() {
260 bool ret = operations_research_model_builderPINVOKE.IntVector_empty(swigCPtr);
261 return ret;
262 }
263
264 private uint capacity() {
265 uint ret = operations_research_model_builderPINVOKE.IntVector_capacity(swigCPtr);
266 return ret;
267 }
268
269 private void reserve(uint n) {
270 operations_research_model_builderPINVOKE.IntVector_reserve(swigCPtr, n);
271 }
272
273 public IntVector(int capacity) : this(operations_research_model_builderPINVOKE.new_IntVector__SWIG_2(capacity), true) {
274 if (operations_research_model_builderPINVOKE.SWIGPendingException.Pending) throw operations_research_model_builderPINVOKE.SWIGPendingException.Retrieve();
276
277 private int getitemcopy(int index) {
280 return ret;
281 }
282
283 private int getitem(int index) {
284 int ret = operations_research_model_builderPINVOKE.IntVector_getitem(swigCPtr, index);
285 if (operations_research_model_builderPINVOKE.SWIGPendingException.Pending) throw operations_research_model_builderPINVOKE.SWIGPendingException.Retrieve();
286 return ret;
287 }
288
289 private void setitem(int index, int val) {
290 operations_research_model_builderPINVOKE.IntVector_setitem(swigCPtr, index, val);
291 if (operations_research_model_builderPINVOKE.SWIGPendingException.Pending) throw operations_research_model_builderPINVOKE.SWIGPendingException.Retrieve();
292 }
293
294 public void AddRange(IntVector values) {
295 operations_research_model_builderPINVOKE.IntVector_AddRange(swigCPtr, IntVector.getCPtr(values));
300 global::System.IntPtr cPtr = operations_research_model_builderPINVOKE.IntVector_GetRange(swigCPtr, index, count);
301 IntVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new IntVector(cPtr, true);
303 return ret;
304 }
305
306 public void Insert(int index, int x) {
327 global::System.IntPtr cPtr = operations_research_model_builderPINVOKE.IntVector_Repeat(value, count);
328 IntVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new IntVector(cPtr, true);
330 return ret;
331 }
332
333 public void Reverse() {
336
337 public void Reverse(int index, int count) {
349 return ret;
350 }
351
352 public int IndexOf(int value) {
354 return ret;
355 }
356
357 public int LastIndexOf(int value) {
359 return ret;
360 }
361
362 public bool Remove(int value) {
364 return ret;
365 }
366
367}
368
369}
void AddRange(IntVector values)
Definition IntVector.cs:296
void Insert(int index, int x)
Definition IntVector.cs:308
void RemoveRange(int index, int count)
Definition IntVector.cs:323
void SetRange(int index, IntVector values)
Definition IntVector.cs:344
void InsertRange(int index, IntVector values)
Definition IntVector.cs:313
static IntVector Repeat(int value, int count)
Definition IntVector.cs:328
IntVector GetRange(int index, int count)
Definition IntVector.cs:301
void CopyTo(int[] array, int arrayIndex)
Definition IntVector.cs:134
static global::System.IntPtr IntVector_GetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static void IntVector_InsertRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3)
static void IntVector_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static void IntVector_RemoveRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static void IntVector_Reverse__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool IntVector_Remove(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static uint IntVector_size(global::System.Runtime.InteropServices.HandleRef jarg1)
static void IntVector_Reverse__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static int IntVector_getitemcopy(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static int IntVector_IndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static global::System.IntPtr IntVector_Repeat(int jarg1, int jarg2)
static void delete_IntVector(global::System.Runtime.InteropServices.HandleRef jarg1)
static void IntVector_Add(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void IntVector_Clear(global::System.Runtime.InteropServices.HandleRef jarg1)
static bool IntVector_Contains(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void IntVector_RemoveAt(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void IntVector_SetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3)
static int IntVector_LastIndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)