DotNet Reference

DotNet Reference

DoubleArrayHelper.cs
Go to the documentation of this file.
1 // Copyright 2010-2018 Google LLC
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13 
15 using System;
16 using System.Collections.Generic;
17 
18 // double[] helper class.
19 public partial class MpDoubleVector: IDisposable, System.Collections.IEnumerable
20 #if !SWIG_DOTNET_1
21  , System.Collections.Generic.IList<double>
22 #endif
23 {
24  // cast from C# double array
25  public static implicit operator MpDoubleVector(double[] inVal) {
26  var outVal= new MpDoubleVector();
27  foreach (double element in inVal) {
28  outVal.Add(element);
29  }
30  return outVal;
31  }
32 
33  // cast to C# double array
34  public static implicit operator double[](MpDoubleVector inVal) {
35  var outVal= new double[inVal.Count];
36  inVal.CopyTo(outVal);
37  return outVal;
38  }
39 }
40 } // namespace Google.OrTools.LinearSolver
MpDoubleVector()