View Javadoc

1   package net.sf.jperfprobe;
2   
3   /**
4    * Created by IntelliJ IDEA.
5    * User: tel
6    * Date: Dec 19, 2008
7    * Time: 10:49:53 AM
8    * To change this template use File | Settings | File Templates.
9    */
10  public class BitSet {
11      private int P[];
12      private int K;
13  
14      public BitSet(int k) {
15          P = new int[k / 32 + 1];
16          K = k;
17      }
18  
19      public void set(int i) {
20          if (i < 0) throw new ArrayIndexOutOfBoundsException("");
21          P[i >> 5] |= (1 << (i & 0x0000001F));
22      }
23  
24      public void clear(int i) {
25          P[i >> 5] &= ~(1 << (i & 0x0000001F));
26      }
27  
28      public boolean get(int i) {
29          return (P[i >> 5] & (1 << (i & 0x0000001F))) != 0;
30      }
31  
32      public int size() {
33          return K;
34      }
35  
36  }