View Javadoc

1   package org.sat4j.core;
2   /*******************************************************************************
3   * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2008 Daniel Le Berre
4   *
5   * All rights reserved. This program and the accompanying materials
6   * are made available under the terms of the Eclipse Public License v1.0
7   * which accompanies this distribution, and is available at
8   * http://www.eclipse.org/legal/epl-v10.html
9   *
10  * Alternatively, the contents of this file may be used under the terms of
11  * either the GNU Lesser General Public License Version 2.1 or later (the
12  * "LGPL"), in which case the provisions of the LGPL are applicable instead
13  * of those above. If you wish to allow use of your version of this file only
14  * under the terms of the LGPL, and not to allow others to use your version of
15  * this file under the terms of the EPL, indicate your decision by deleting
16  * the provisions above and replace them with the notice and other provisions
17  * required by the LGPL. If you do not delete the provisions above, a recipient
18  * may use your version of this file under the terms of the EPL or the LGPL.
19  * 
20  * Based on the original MiniSat specification from:
21  * 
22  * An extensible SAT solver. Niklas Een and Niklas Sorensson. Proceedings of the
23  * Sixth International Conference on Theory and Applications of Satisfiability
24  * Testing, LNCS 2919, pp 502-518, 2003.
25  *
26  * See www.minisat.se for the original solver in C++.
27  * 
28  *******************************************************************************/
29  import java.util.Comparator;
30  import java.util.Iterator;
31  
32  import org.sat4j.specs.IVec;
33  
34  /**
35   * Utility class to allow Read Only access to an IVec<T>.
36   * 
37   * @author daniel
38   *
39   * @param <T> the type of the container.
40   */
41  public class ReadOnlyVec<T> implements IVec<T> {
42  
43      /**
44  	 * 
45  	 */
46  	private static final long serialVersionUID = 1L;
47  	
48  	private final IVec<T> vec;
49  
50      public ReadOnlyVec(IVec<T> vec) {
51          this.vec = vec;
52      }
53  
54      public void clear() {
55          throw new UnsupportedOperationException();
56      }
57  
58      public void copyTo(IVec<T> copy) {
59          vec.copyTo(copy);
60      }
61  
62      public <E> void copyTo(E[] dest) {
63          vec.copyTo(dest);
64      }
65  
66      public T delete(int i) {
67          throw new UnsupportedOperationException();
68      }
69  
70      public void ensure(int nsize) {
71          throw new UnsupportedOperationException();
72  
73      }
74  
75      public T get(int i) {
76          return vec.get(i);
77      }
78  
79      public void growTo(int newsize, T pad) {
80          throw new UnsupportedOperationException();
81      }
82  
83      public void insertFirst(T elem) {
84          throw new UnsupportedOperationException();
85      }
86  
87      public void insertFirstWithShifting(T elem) {
88          throw new UnsupportedOperationException();
89      }
90  
91      public boolean isEmpty() {
92          return vec.isEmpty();
93      }
94  
95      public Iterator<T> iterator() {
96          return vec.iterator();
97      }
98  
99      public T last() {
100         return vec.last();
101     }
102 
103     public void moveTo(IVec<T> dest) {
104         throw new UnsupportedOperationException();
105     }
106 
107     public void moveTo(int dest, int source) {
108         throw new UnsupportedOperationException();
109     }
110 
111     public void pop() {
112         throw new UnsupportedOperationException();
113     }
114 
115     public IVec<T> push(Object elem) {
116         throw new UnsupportedOperationException();
117     }
118 
119     public void remove(Object elem) {
120         throw new UnsupportedOperationException();
121     }
122 
123     public void set(int i, Object o) {
124         throw new UnsupportedOperationException();
125     }
126 
127     public void shrink(int nofelems) {
128         throw new UnsupportedOperationException();
129     }
130 
131     public void shrinkTo(int newsize) {
132         throw new UnsupportedOperationException();
133     }
134 
135     public int size() {
136         return vec.size();
137     }
138 
139     public void sort(Comparator<T> comparator) {
140         throw new UnsupportedOperationException();
141     }
142 
143     public void sortUnique(Comparator<T> comparator) {
144         throw new UnsupportedOperationException();
145     }
146 
147     @SuppressWarnings("unchecked")
148 	public T[] toArray() {
149         T[] array = (T[])new Object[vec.size()];
150         vec.copyTo(array);
151         return array;
152     }
153 
154     public void unsafePush(T elem) {
155         throw new UnsupportedOperationException();
156     }
157 
158 }