Google OR-Tools v9.11
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
MPVariableVector.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 partial class MPVariableVector : global::System.IDisposable, global::System.Collections.IEnumerable, global::System.Collections.Generic.IList<Variable>
14 {
15 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
16 protected bool swigCMemOwn;
17
18 internal MPVariableVector(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(MPVariableVector 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(MPVariableVector 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 ~MPVariableVector() {
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 MPVariableVector(global::System.Collections.IEnumerable c) : this() {
62 if (c == null)
63 throw new global::System.ArgumentNullException("c");
64 foreach (Variable element in c) {
65 this.Add(element);
66 }
67 }
68
69 public MPVariableVector(global::System.Collections.Generic.IEnumerable<Variable> c) : this() {
70 if (c == null)
71 throw new global::System.ArgumentNullException("c");
72 foreach (Variable 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 Variable 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(Variable[] array)
128 {
129 CopyTo(0, array, 0, this.Count);
130 }
131
132 public void CopyTo(Variable[] array, int arrayIndex)
133 {
134 CopyTo(0, array, arrayIndex, this.Count);
135 }
136
137 public void CopyTo(int index, Variable[] 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 Variable[] ToArray() {
156 Variable[] array = new Variable[this.Count];
157 this.CopyTo(array);
158 return array;
159 }
160
161 global::System.Collections.Generic.IEnumerator<Variable> global::System.Collections.Generic.IEnumerable<Variable>.GetEnumerator() {
162 return new MPVariableVectorEnumerator(this);
163 }
164
165 global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator() {
166 return new MPVariableVectorEnumerator(this);
167 }
168
169 public MPVariableVectorEnumerator GetEnumerator() {
170 return new MPVariableVectorEnumerator(this);
172
173 // Type-safe enumerator
178 public sealed class MPVariableVectorEnumerator : global::System.Collections.IEnumerator
179 , global::System.Collections.Generic.IEnumerator<Variable>
181 private MPVariableVector collectionRef;
182 private int currentIndex;
183 private object currentObject;
184 private int currentSize;
185
187 collectionRef = collection;
188 currentIndex = -1;
189 currentObject = null;
190 currentSize = collectionRef.Count;
191 }
192
193 // Type-safe iterator Current
194 public Variable 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 (Variable)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 MPVariableVector() : this(operations_research_linear_solverPINVOKE.new_MPVariableVector__SWIG_0(), true) {
240 }
242 public MPVariableVector(MPVariableVector other) : this(operations_research_linear_solverPINVOKE.new_MPVariableVector__SWIG_1(MPVariableVector.getCPtr(other)), true) {
245
246 public void Clear() {
249
250 public void Add(Variable x) {
253
254 private uint size() {
256 return ret;
257 }
258
259 private bool empty() {
260 bool ret = operations_research_linear_solverPINVOKE.MPVariableVector_empty(swigCPtr);
261 return ret;
262 }
263
264 private uint capacity() {
265 uint ret = operations_research_linear_solverPINVOKE.MPVariableVector_capacity(swigCPtr);
266 return ret;
267 }
268
269 private void reserve(uint n) {
270 operations_research_linear_solverPINVOKE.MPVariableVector_reserve(swigCPtr, n);
271 }
272
273 public MPVariableVector(int capacity) : this(operations_research_linear_solverPINVOKE.new_MPVariableVector__SWIG_2(capacity), true) {
274 if (operations_research_linear_solverPINVOKE.SWIGPendingException.Pending) throw operations_research_linear_solverPINVOKE.SWIGPendingException.Retrieve();
276
277 private Variable getitemcopy(int index) {
278 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.MPVariableVector_getitemcopy(swigCPtr, index);
279 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
281 return ret;
282 }
283
284 private Variable getitem(int index) {
285 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.MPVariableVector_getitem(swigCPtr, index);
286 Variable ret = (cPtr == global::System.IntPtr.Zero) ? null : new Variable(cPtr, false);
287 if (operations_research_linear_solverPINVOKE.SWIGPendingException.Pending) throw operations_research_linear_solverPINVOKE.SWIGPendingException.Retrieve();
288 return ret;
289 }
290
291 private void setitem(int index, Variable val) {
292 operations_research_linear_solverPINVOKE.MPVariableVector_setitem(swigCPtr, index, Variable.getCPtr(val));
293 if (operations_research_linear_solverPINVOKE.SWIGPendingException.Pending) throw operations_research_linear_solverPINVOKE.SWIGPendingException.Retrieve();
294 }
295
296 public void AddRange(MPVariableVector values) {
297 operations_research_linear_solverPINVOKE.MPVariableVector_AddRange(swigCPtr, MPVariableVector.getCPtr(values));
302 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.MPVariableVector_GetRange(swigCPtr, index, count);
303 MPVariableVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new MPVariableVector(cPtr, true);
305 return ret;
306 }
307
308 public void Insert(int index, Variable x) {
329 global::System.IntPtr cPtr = operations_research_linear_solverPINVOKE.MPVariableVector_Repeat(Variable.getCPtr(value), count);
330 MPVariableVector ret = (cPtr == global::System.IntPtr.Zero) ? null : new MPVariableVector(cPtr, true);
332 return ret;
333 }
334
335 public void Reverse() {
338
339 public void Reverse(int index, int count) {
351 return ret;
352 }
353
354 public int IndexOf(Variable value) {
356 return ret;
357 }
358
359 public int LastIndexOf(Variable value) {
361 return ret;
362 }
363
364 public bool Remove(Variable value) {
366 return ret;
367 }
368
369}
370
371}
MPVariableVector GetRange(int index, int count)
static MPVariableVector Repeat(Variable value, int count)
void SetRange(int index, MPVariableVector values)
void CopyTo(Variable[] array, int arrayIndex)
void InsertRange(int index, MPVariableVector values)
Patch the MPVariable class to support the natural language API.
Definition Variable.cs:15
static void MPVariableVector_RemoveAt(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static bool MPVariableVector_Contains(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void MPVariableVector_InsertRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3)
static void MPVariableVector_Reverse__SWIG_1(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static bool MPVariableVector_Remove(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static int MPVariableVector_LastIndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static uint MPVariableVector_size(global::System.Runtime.InteropServices.HandleRef jarg1)
static global::System.IntPtr MPVariableVector_GetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static void MPVariableVector_RemoveRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, int jarg3)
static void MPVariableVector_Clear(global::System.Runtime.InteropServices.HandleRef jarg1)
static void MPVariableVector_SetRange(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3)
static global::System.IntPtr MPVariableVector_getitemcopy(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)
static void MPVariableVector_Insert(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2, global::System.Runtime.InteropServices.HandleRef jarg3)
static void MPVariableVector_Reverse__SWIG_0(global::System.Runtime.InteropServices.HandleRef jarg1)
static void MPVariableVector_Add(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static void delete_MPVariableVector(global::System.Runtime.InteropServices.HandleRef jarg1)
static int MPVariableVector_IndexOf(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2)
static global::System.IntPtr MPVariableVector_Repeat(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2)