View Javadoc

1   /*******************************************************************************
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004, 2012 Artois University and CNRS
3    *
4    * All rights reserved. This program and the accompanying materials
5    * are made available under the terms of the Eclipse Public License v1.0
6    * which accompanies this distribution, and is available at
7    *  http://www.eclipse.org/legal/epl-v10.html
8    *
9    * Alternatively, the contents of this file may be used under the terms of
10   * either the GNU Lesser General Public License Version 2.1 or later (the
11   * "LGPL"), in which case the provisions of the LGPL are applicable instead
12   * of those above. If you wish to allow use of your version of this file only
13   * under the terms of the LGPL, and not to allow others to use your version of
14   * this file under the terms of the EPL, indicate your decision by deleting
15   * the provisions above and replace them with the notice and other provisions
16   * required by the LGPL. If you do not delete the provisions above, a recipient
17   * may use your version of this file under the terms of the EPL or the LGPL.
18   *
19   * Based on the original MiniSat specification from:
20   *
21   * An extensible SAT solver. Niklas Een and Niklas Sorensson. Proceedings of the
22   * Sixth International Conference on Theory and Applications of Satisfiability
23   * Testing, LNCS 2919, pp 502-518, 2003.
24   *
25   * See www.minisat.se for the original solver in C++.
26   *
27   * Contributors:
28   *   CRIL - initial API and implementation
29   *******************************************************************************/
30  package org.sat4j.core;
31  
32  import org.sat4j.specs.IVecInt;
33  import org.sat4j.specs.IteratorInt;
34  
35  /**
36   * Utility class to allow Read Only access only to an IVecInt.
37   * 
38   * @author daniel
39   * 
40   */
41  public final class ReadOnlyVecInt implements IVecInt {
42  
43      /**
44  	 * 
45  	 */
46      private static final long serialVersionUID = 1L;
47  
48      private final IVecInt vec;
49  
50      public ReadOnlyVecInt(IVecInt vec) {
51          this.vec = vec;
52      }
53  
54      public void clear() {
55          throw new UnsupportedOperationException();
56      }
57  
58      public boolean contains(int e) {
59          return this.vec.contains(e);
60      }
61  
62      public int containsAt(int e) {
63          return this.vec.containsAt(e);
64      }
65  
66      public int containsAt(int e, int from) {
67          return this.vec.containsAt(e, from);
68      }
69  
70      public void copyTo(IVecInt copy) {
71          this.vec.copyTo(copy);
72      }
73  
74      public void copyTo(int[] is) {
75          this.vec.copyTo(is);
76      }
77  
78      public int delete(int i) {
79          throw new UnsupportedOperationException();
80      }
81  
82      public void ensure(int nsize) {
83          throw new UnsupportedOperationException();
84      }
85  
86      public int get(int i) {
87          return this.vec.get(i);
88      }
89  
90      public void growTo(int newsize, int pad) {
91          throw new UnsupportedOperationException();
92      }
93  
94      public void insertFirst(int elem) {
95          throw new UnsupportedOperationException();
96      }
97  
98      public boolean isEmpty() {
99          return this.vec.isEmpty();
100     }
101 
102     public IteratorInt iterator() {
103         return this.vec.iterator();
104     }
105 
106     public int last() {
107         return this.vec.last();
108     }
109 
110     public void moveTo(IVecInt dest) {
111         throw new UnsupportedOperationException();
112     }
113 
114     public void moveTo(int[] dest) {
115         throw new UnsupportedOperationException();
116     }
117 
118     public void moveTo(int dest, int source) {
119         throw new UnsupportedOperationException();
120     }
121 
122     public void moveTo2(IVecInt dest) {
123         throw new UnsupportedOperationException();
124     }
125 
126     public IVecInt pop() {
127         throw new UnsupportedOperationException();
128     }
129 
130     public IVecInt push(int elem) {
131         throw new UnsupportedOperationException();
132     }
133 
134     public void remove(int elem) {
135         throw new UnsupportedOperationException();
136     }
137 
138     public void set(int i, int o) {
139         throw new UnsupportedOperationException();
140     }
141 
142     public void shrink(int nofelems) {
143         throw new UnsupportedOperationException();
144     }
145 
146     public void shrinkTo(int newsize) {
147         throw new UnsupportedOperationException();
148     }
149 
150     public int size() {
151         return this.vec.size();
152     }
153 
154     public void sort() {
155         throw new UnsupportedOperationException();
156     }
157 
158     public void sortUnique() {
159         throw new UnsupportedOperationException();
160     }
161 
162     public int unsafeGet(int eleem) {
163         return this.vec.unsafeGet(eleem);
164     }
165 
166     public void unsafePush(int elem) {
167         throw new UnsupportedOperationException();
168     }
169 
170     /**
171      * @since 2.1
172      */
173     public int[] toArray() {
174         throw new UnsupportedOperationException();
175     }
176 
177     /**
178      * @since 2.2
179      */
180     public int indexOf(int e) {
181         return this.vec.indexOf(e);
182     }
183 
184     @Override
185     public String toString() {
186         return this.vec.toString();
187     }
188 
189     public void moveTo(int sourceStartingIndex, int[] dest) {
190         throw new UnsupportedOperationException();
191     }
192 
193     /**
194      * 
195      * @author sroussel
196      * @since 2.3.1
197      */
198     public VecInt[] subset(int cardinal) {
199         return null;
200     }
201 
202     @Override
203     public int hashCode() {
204         return this.vec.hashCode();
205     }
206 
207     @Override
208     public boolean equals(Object obj) {
209         return this.vec.equals(obj);
210     }
211 
212 }