View Javadoc

1   /*******************************************************************************
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
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   *******************************************************************************/
28  package org.sat4j.core;
29  
30  import org.sat4j.specs.IVecInt;
31  import org.sat4j.specs.IteratorInt;
32  
33  /**
34   * Utility class to allow Read Only access only to an IVecInt.
35   * 
36   * @author daniel
37   * 
38   */
39  public final class ReadOnlyVecInt implements IVecInt {
40  
41  	/**
42  	 * 
43  	 */
44  	private static final long serialVersionUID = 1L;
45  
46  	private final IVecInt vec;
47  
48  	public ReadOnlyVecInt(IVecInt vec) {
49  		this.vec = vec;
50  	}
51  
52  	public void clear() {
53  		throw new UnsupportedOperationException();
54  	}
55  
56  	public boolean contains(int e) {
57  		return vec.contains(e);
58  	}
59  
60  	public int containsAt(int e) {
61  		return vec.containsAt(e);
62  	}
63  
64  	public int containsAt(int e, int from) {
65  		return vec.containsAt(e, from);
66  	}
67  
68  	public void copyTo(IVecInt copy) {
69  		vec.copyTo(copy);
70  	}
71  
72  	public void copyTo(int[] is) {
73  		vec.copyTo(is);
74  	}
75  
76  	public int delete(int i) {
77  		throw new UnsupportedOperationException();
78  	}
79  
80  	public void ensure(int nsize) {
81  		throw new UnsupportedOperationException();
82  	}
83  
84  	public int get(int i) {
85  		return vec.get(i);
86  	}
87  
88  	public void growTo(int newsize, int pad) {
89  		throw new UnsupportedOperationException();
90  	}
91  
92  	public void insertFirst(int elem) {
93  		throw new UnsupportedOperationException();
94  	}
95  
96  	public boolean isEmpty() {
97  		return vec.isEmpty();
98  	}
99  
100 	public IteratorInt iterator() {
101 		return vec.iterator();
102 	}
103 
104 	public int last() {
105 		return vec.last();
106 	}
107 
108 	public void moveTo(IVecInt dest) {
109 		throw new UnsupportedOperationException();
110 	}
111 
112 	public void moveTo(int[] dest) {
113 		throw new UnsupportedOperationException();
114 	}
115 
116 	public void moveTo(int dest, int source) {
117 		throw new UnsupportedOperationException();
118 	}
119 
120 	public void moveTo2(IVecInt dest) {
121 		throw new UnsupportedOperationException();
122 	}
123 
124 	public IVecInt pop() {
125 		throw new UnsupportedOperationException();
126 	}
127 
128 	public IVecInt push(int elem) {
129 		throw new UnsupportedOperationException();
130 	}
131 
132 	public void remove(int elem) {
133 		throw new UnsupportedOperationException();
134 	}
135 
136 	public void set(int i, int o) {
137 		throw new UnsupportedOperationException();
138 	}
139 
140 	public void shrink(int nofelems) {
141 		throw new UnsupportedOperationException();
142 	}
143 
144 	public void shrinkTo(int newsize) {
145 		throw new UnsupportedOperationException();
146 	}
147 
148 	public int size() {
149 		return vec.size();
150 	}
151 
152 	public void sort() {
153 		throw new UnsupportedOperationException();
154 	}
155 
156 	public void sortUnique() {
157 		throw new UnsupportedOperationException();
158 	}
159 
160 	public int unsafeGet(int eleem) {
161 		return vec.unsafeGet(eleem);
162 	}
163 
164 	public void unsafePush(int elem) {
165 		throw new UnsupportedOperationException();
166 	}
167 
168 	/**
169 	 * @since 2.1
170 	 */
171 	public int[] toArray() {
172 		throw new UnsupportedOperationException();
173 	}
174 
175 	/**
176 	 * @since 2.2
177 	 */
178 	public int indexOf(int e) {
179 		return vec.indexOf(e);
180 	}
181 
182 	@Override
183 	public String toString() {
184 		return vec.toString();
185 	}
186 
187 }