IntVar.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 package org.gecode;
00010
00016 public class IntVar implements GecodeVar {
00017 private long swigCPtr;
00018 protected boolean swigCMemOwn;
00019
00020 protected IntVar(long cPtr, boolean cMemoryOwn) {
00021 swigCMemOwn = cMemoryOwn;
00022 swigCPtr = cPtr;
00023 }
00024
00025 protected static long getCPtr(IntVar obj) {
00026 return (obj == null) ? 0 : obj.swigCPtr;
00027 }
00028
00029 protected void finalize() {
00030 delete();
00031 }
00032
00033 public void delete() {
00034 if(swigCPtr != 0 && swigCMemOwn) {
00035 swigCMemOwn = false;
00036 GecodeJNI.delete_IntVar(swigCPtr);
00037 }
00038 swigCPtr = 0;
00039 }
00040
00041 protected static long[] cArrayUnwrap(VarArray<? extends IntVar> arrayWrapper) {
00042 long[] cArray = new long[arrayWrapper.size()];
00043 for (int i=0; i<arrayWrapper.size(); i++)
00044 cArray[i] = IntVar.getCPtr(arrayWrapper.get(i));
00045 return cArray;
00046 }
00047
00048 protected static VarArray<IntVar> cArrayWrap(long[] cArray,
00049 boolean cMemoryOwn) {
00050 VarArray<IntVar> arrayWrapper = new VarArray<IntVar>(cArray.length);
00051 for (int i=0; i<cArray.length; i++)
00052 arrayWrapper.add(i, new IntVar(cArray[i], cMemoryOwn));
00053 return arrayWrapper;
00054 }
00055
00056 public IntVar(JavaSpace home, IntSet dom) {
00059 this(GecodeJNI.new_IntVar__SWIG_0(JavaSpace.getCPtr(home), IntSet.getCPtr(dom)), true);
00060 }
00061
00062 public IntVar(JavaSpace home, String name, IntSet dom) {
00065 this(GecodeJNI.new_IntVar__SWIG_1(JavaSpace.getCPtr(home), name, IntSet.getCPtr(dom)), true);
00066 }
00067
00068 public IntVar(JavaSpace home, Integer domMin, Integer domMax) {
00071 this(GecodeJNI.new_IntVar__SWIG_2(JavaSpace.getCPtr(home), domMin.intValue(), domMax.intValue()), true);
00072 }
00073
00074 public IntVar(JavaSpace home, String name, Integer domMin, Integer domMax) {
00077 this(GecodeJNI.new_IntVar__SWIG_3(JavaSpace.getCPtr(home), name, domMin.intValue(), domMax.intValue()), true);
00078 }
00079
00080 public synchronized IntVar copy(JavaSpace newHome, boolean share) {
00083 return new IntVar(GecodeJNI.IntVar_copy(swigCPtr, JavaSpace.getCPtr(newHome), share), true);
00084 }
00085
00086 public synchronized int min() {
00089 return GecodeJNI.IntVar_min(swigCPtr);
00090 }
00091
00092 public synchronized int max() {
00095 return GecodeJNI.IntVar_max(swigCPtr);
00096 }
00097
00098 public synchronized int val() {
00101 return GecodeJNI.IntVar_val(swigCPtr);
00102 }
00103
00104 public synchronized boolean in(int val) {
00107 return GecodeJNI.IntVar_in(swigCPtr, val);
00108 }
00109
00110 public synchronized boolean assigned() {
00113 return GecodeJNI.IntVar_assigned(swigCPtr);
00114 }
00115
00116 public synchronized String toString() {
00119 return GecodeJNI.IntVar_toString(swigCPtr);
00120 }
00121
00122 public synchronized String getName() {
00125 return GecodeJNI.IntVar_getName(swigCPtr);
00126 }
00127
00128 }