Packages This Package Prev Next Index

public final class java.util.This class implements a vector of bits that grows as needed. Each component of the bit set has a boolean value. The bits of a BitSet are inded by nonnegative integers. Individual bits can be examined, set, or cleared.BitSetextends java.lang.Object(I-§1.12) implements java.lang.Cloneable(I-§1.22) { // Constructors publicBitSet(); §3.1.1 publicBitSet(int nbits); §3.1.2 // Methods public voidand(BitSet set); §3.1.3 public voidclear(int bit); §3.1.4 public Objectclone(); §3.1.5 public booleanequals(Object obj); §3.1.6 public booleanget(int bit); §3.1.7 public inthashCode(); §3.1.8 public voidor(BitSet set); §3.1.9 public voidset(int bit); §3.1.10 public intsize(); §3.1.11 public StringtoString(); §3.1.12 public voidxor(BitSet set); §3.1.13 }

By default, all bits in the set initially have the value false.

Every bit set has a current size, which is the number of bits currently in the bit set.

```
public BitSet()
```

- Creates a new bit set. All bits are initially false.

```
public BitSet(int nbits)
```

- Creates a bit set whose initial size is the specified number of bits. All bits
are initially false.
**Parameters:**`nbits -`

the initial size of the bit set.

```
public void and(BitSet set)
```

- Performs a logical
**and**of this target bit set with the argument bit set. This bit set is modified so that each bit in it has the value true if and only if it both initially had the value true and the corresponding bit in the bit set argument also had the value true.**Parameters:**`set -`

a bit set

```
public void clear(int bit)
```

- Sets the bit specified by the index to false.
**Parameters:**`bit -`

the index of the bit to be cleared

```
public Object clone()
```

- The clone of the bit set is another bit set that has exactly the same bits set
to true as this bit set and the same current size (I-§3.1.11).
**Returns:**- a clone of this bit set.
**Overrides:**- clone in class Object (I-§1.12.2).

```
public boolean equals(Object obj)
```

- The result is true if and only if the argument is not null and is a Bitset object
that has exactly the same set of bits set to true as this bit set. The current
sizes (I-§3.1.11) of the two bit sets are not compared.
**Parameters:**`obj -`

the object to compare with**Returns:**- true if the objects are the same; false otherwise.
**Overrides:**- equals in class Object (I-§1.12.3).

```
public boolean get(int bit)
```

**Parameters:**`bit -`

the bit index**Returns:**- the value of the bit with the specified index.

```
public int hashCode()
```

**Returns:**- a hash code value for this bit set.
**Overrides:**- hashCode in class Object (I-§1.12.6).

```
public void or(BitSet set)
```

- Performs a logical
**or**of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if it either already had the value true or the corresponding bit in the bit set argument has the value true.**Parameters:**`set -`

a bit set

```
public void set(int bit)
```

- Sets the bit specified by the index to true.
**Parameters:**`bit -`

a bit index.

```
public int size()
```

**Returns:**- the number of bits currently in this bit set.

```
public String toString()
```

**Returns:**- a string representation of this bit set.
**Overrides:**- toString in class Object (I-§1.12.9).

```
public void xor(BitSet set)
```

- Performs a logical x
**or**of this bit set with the bit set argument. This bit set is modified so that a bit in it has the value true if and only if one of the following statements holds:

Packages This Package Prev Next IndexJava API Document (HTML generated by dkramer on April 22, 1996)

Copyright © 1996 Sun Microsystems, Inc. All rights reserved

Please send any comments or corrections to doug.kramer@sun.com