Package org.postgresql.util.internal
Class IntSet
- java.lang.Object
-
- org.postgresql.util.internal.IntSet
-
public final class IntSet extends java.lang.Object
Read-optimizedSet
for storingOid
values. Note: the set does not support nullable values.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.BitSet
bitSet
Contains values in range of [0..MAX_OID_TO_STORE_IN_BITSET].private static int
MAX_OID_TO_STORE_IN_BITSET
Maximal Oid that will bs stored inBitSet
.private java.util.Set<java.lang.Integer>
set
Contains values outside [0..MAX_OID_TO_STORE_IN_BITSET] range.
-
Constructor Summary
Constructors Constructor Description IntSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(int value)
Adds a single value to the set.void
addAll(java.util.Collection<? extends java.lang.Integer> values)
Adds all the values to the set.void
clear()
Clears the contents of the set.boolean
contains(int value)
Checks if a given value belongs to the set.boolean
remove(int value)
Removes a value from the set.java.util.Set<java.lang.Integer>
toMutableSet()
Returns a mutable snapshot of the values stored in the current set.
-
-
-
Field Detail
-
MAX_OID_TO_STORE_IN_BITSET
private static final int MAX_OID_TO_STORE_IN_BITSET
Maximal Oid that will bs stored inBitSet
. If Oid exceeds this value, then it will be stored inSet<Int>
only. In theory, Oids can be up to 32bit, so we want to limit per-connection memory utilization. AllowBitSet
to consume up to 8KiB (one for send and one for receive).- See Also:
- Constant Field Values
-
set
private java.util.Set<java.lang.Integer> set
Contains values outside [0..MAX_OID_TO_STORE_IN_BITSET] range. This field is null if bitSet contains all the values.
-
bitSet
private final java.util.BitSet bitSet
Contains values in range of [0..MAX_OID_TO_STORE_IN_BITSET].
-
-
Method Detail
-
clear
public void clear()
Clears the contents of the set.
-
addAll
public void addAll(java.util.Collection<? extends java.lang.Integer> values)
Adds all the values to the set.- Parameters:
values
- set of values to add
-
add
public boolean add(int value)
Adds a single value to the set.- Parameters:
value
- value to add- Returns:
- true if the set did not already contain the specified value
-
remove
public boolean remove(int value)
Removes a value from the set.- Parameters:
value
- value to remove- Returns:
- true if the element was
-
contains
public boolean contains(int value)
Checks if a given value belongs to the set.- Parameters:
value
- value to check- Returns:
- true if the value belons to the set
-
toMutableSet
public java.util.Set<java.lang.Integer> toMutableSet()
Returns a mutable snapshot of the values stored in the current set.- Returns:
- a mutable snapshot of the values stored in the current set
-
-