Clover Coverage Report
Coverage timestamp: mer. juin 27 2007 07:27:16 CEST
18   120   4   3
10   45   0,5   6
6     1,5  
1    
 
  IntQueue       Line # 38 18 4 50% 0.5
 
  (4)
 
1    /*
2    * SAT4J: a SATisfiability library for Java Copyright (C) 2004-2006 Daniel Le Berre
3    *
4    * Based on the original minisat specification from:
5    *
6    * An extensible SAT solver. Niklas E?n and Niklas S?rensson. Proceedings of the
7    * Sixth International Conference on Theory and Applications of Satisfiability
8    * Testing, LNCS 2919, pp 502-518, 2003.
9    *
10    * This library is free software; you can redistribute it and/or modify it under
11    * the terms of the GNU Lesser General Public License as published by the Free
12    * Software Foundation; either version 2.1 of the License, or (at your option)
13    * any later version.
14    *
15    * This library is distributed in the hope that it will be useful, but WITHOUT
16    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17    * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
18    * details.
19    *
20    * You should have received a copy of the GNU Lesser General Public License
21    * along with this library; if not, write to the Free Software Foundation, Inc.,
22    * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23    *
24    */
25   
26    package org.sat4j.minisat.core;
27   
28    import java.io.Serializable;
29   
30    /**
31    * Implementation of a queue.
32    *
33    * Formerly used in the solver to maintain unit literals for unit propagation.
34    * No longer used currently.
35    *
36    * @author leberre
37    */
 
38    public final class IntQueue implements Serializable {
39   
40    private static final long serialVersionUID = 1L;
41   
42    private static final int INITIAL_QUEUE_CAPACITY = 10;
43   
44    /**
45    * Add an element to the queue. The queue is supposed to be large enough for
46    * that!
47    *
48    * @param x
49    * the element to add
50    */
 
51  24 toggle public void insert(final int x) {
52    // ensure(size + 1);
53  24 assert size < myarray.length;
54  24 myarray[size++] = x;
55    }
56   
57    /**
58    * returns the nexdt element in the queue. Unexpected results if the queue
59    * is empty!
60    *
61    * @return the firsst element on the queue
62    */
 
63  20 toggle public int dequeue() {
64  20 assert first < size;
65  20 return myarray[first++];
66    }
67   
68    /**
69    * Vide la queue
70    */
 
71  1 toggle public void clear() {
72  1 size = 0;
73  1 first = 0;
74    }
75   
76    /**
77    * Pour connaitre la taille de la queue.
78    *
79    * @return le nombre d'elements restant dans la queue
80    */
 
81  11 toggle public int size() {
82  11 return size - first;
83    }
84   
85    /**
86    * Utilisee pour accroitre dynamiquement la taille de la queue.
87    *
88    * @param nsize
89    * la taille maximale de la queue
90    */
 
91  1 toggle public void ensure(final int nsize) {
92  1 if (nsize >= myarray.length) {
93  1 int[] narray = new int[Math.max(nsize, size * 2)];
94  1 System.arraycopy(myarray, 0, narray, 0, size);
95  1 myarray = narray;
96    }
97    }
98   
 
99  0 toggle @Override
100    public String toString() {
101  0 StringBuffer stb = new StringBuffer();
102  0 stb.append(">"); //$NON-NLS-1$
103  0 for (int i = first; i < size - 1; i++) {
104  0 stb.append(myarray[i]);
105  0 stb.append(" "); //$NON-NLS-1$
106    }
107  0 if (first != size) {
108  0 stb.append(myarray[size - 1]);
109    }
110  0 stb.append("<"); //$NON-NLS-1$
111  0 return stb.toString();
112    }
113   
114    private int[] myarray = new int[INITIAL_QUEUE_CAPACITY];
115   
116    private int size = 0;
117   
118    private int first = 0;
119   
120    }