本文共 3267 字,大约阅读时间需要 10 分钟。
c bitset get
Syntax:
句法:
public boolean get(int bit_in); public BitSet get(int st_in, int en_in);
get() method is available in java.util package.
get()方法在java.util包中可用。
get(int bit_in) method is used to return the value of the given bit indices (bit_in). It returns true when the bit with the given index is set by using the set() method.
get(int bit_in)方法用于返回给定位索引(bit_in)的值。 当使用set()方法设置具有给定索引的位时,它返回true。
get(int st_in, int en_in) method is used to returns a subset consisted of bits from this BitSet from the given range st_in(starting index) and en_in(ending index).
get(int st_in,int en_in)方法用于从给定范围st_in (起始索引)和en_in (结束索引)返回该BitSet中的位组成的子集。
get(int bit_in) method may throw an exception at the time of checking index.
在检查索引时, get(int bit_in)方法可能会引发异常。
IndexOutOfBoundsException: This exception may throw when the given index is less than 0.
IndexOutOfBoundsException :当给定索引小于0时,可能引发此异常。
get(int st_in, int en_in) method may throw an exception at the time of checking exception.
在检查异常时, get(int st_in,int en_in)方法可能会引发异常。
IndexOutOfBoundsException: This exception may throw when st_in or en_in is less than 0 or st_in > en_in.
IndexOutOfBoundsException :当st_in或en_in小于0或st_in> en_in时,可能引发此异常。
These are non-static methods, so it is accessible with the class object and if we try to access these methods with the class name then we will get an error.
这些是非静态方法,因此可以通过类对象进行访问,如果尝试使用类名称访问这些方法,则会收到错误消息。
Parameter(s):
参数:
In the second case, get(int bit_in)
在第二种情况下, get(int bit_in)
In the third case, get(int st_in, int en_in)
在第三种情况下, get(int st_in,int en_in)
Return value:
返回值:
In the first case, boolean get(bit_in): The return type of the method is boolean, it returns true when it returns the value of the bit of the given index.
在第一种情况下, boolean get(bit_in) :方法的返回类型为boolean ,当它返回给定索引的bit值时返回true。
In the second case, BitSet get(int st_in, int en_in), it returns BitSet of the given range (st_in & en_in).
在第二种情况下, BitSet get(int st_in,int en_in) ,它返回给定范围( st_in&en_in )的BitSet。
Example:
例:
// Java program to demonstrate the example // of get() method of BitSet.import java.util.*;public class GetOfBitSet { public static void main(String[] args) { // create an object of BitSet BitSet bs = new BitSet(10); // By using set() method is to set // the values in BitSet bs.set(10); bs.set(20); bs.set(30); bs.set(40); bs.set(50); bs.set(60); bs.set(70); bs.set(80); // Display Bitset System.out.println("bs: " + bs); // By using get(40) method is used to // check the given bit exists in this BitSet or not boolean status = bs.get(40); // Display status System.out.println("bs.get(40): " + status); // By using get(40,60) method is used to // check the given set of bits exists in this // BitSet or not // Display Bitset System.out.println("bs.get(40,60): " + bs.get(40, 60)); }}
Output
输出量
bs: {10, 20, 30, 40, 50, 60, 70, 80}bs.get(40): truebs.get(40,60): {0, 10}
翻译自:
c bitset get
转载地址:http://jvtzd.baihongyu.com/