GlueGen: com.jogamp.common.util.Bitfield.Util Class Reference

GlueGen v2.6.0-rc-20250722 GlueGen, Native Binding Generator for Java™ (public API).

Static Public Member Functions | Static Public Attributes | List of all members
com.jogamp.common.util.Bitfield.Util Class Reference

Bit operation utilities (static). More...

Collaboration diagram for com.jogamp.common.util.Bitfield.Util:

## Static Public Member Functions

static int | getBitMask (final int n)
| Returns the 32 bit mask of n-bits, i.e. More...
static final int | bitCount (int n)
| Returns the number of set bits within given 32bit integer in O(1) using a HAKEM 169 Bit Count inspired implementation: More...
static final boolean | isPowerOf2 (final int n)
| Returns `true` if the given integer is a power of 2. More...
static final int | nextPowerOf2 (int n)
| Returns the next higher power of 2 of 32-bit of given `n @endiliteral. ` More...
static final int | roundToPowerOf2 (final int n)
| If the given `n` is not `isPowerOf2(int)` return `nextPowerOf2(int)`, otherwise return `n` unchanged. More...

## Static Public Attributes

static final int | MAX_POWER_OF_2 = 1 << ( Integer.SIZE - 2 )
| Maximum 32bit integer value being of `isPowerOf2(int)`. More...

## Detailed Description

Bit operation utilities (static).

Definition at line 43 of file Bitfield.java.

## Member Function Documentation

## ◆ bitCount()

static final int com.jogamp.common.util.Bitfield.Util.bitCount | ( | int | n | ) |

static

Returns the number of set bits within given 32bit integer in O(1) using a HAKEM 169 Bit Count inspired implementation:

      http://www.inwap.com/pdp10/hbaker/hakmem/hakmem.html
      http://home.pipeline.com/~hbaker1/hakmem/hacks.html#item169
      http://tekpool.wordpress.com/category/bit-count/
      http://www.hackersdelight.org/

<p<blockquote>‍

We rely on the JVM spec `Integer#SIZE` == 32.

Definition at line 82 of file Bitfield.java.

Here is the caller graph for this function:

## ◆ getBitMask()

static int com.jogamp.common.util.Bitfield.Util.getBitMask | ( | final int | n | ) |

static

Returns the 32 bit mask of n-bits, i.e.

n low order 1’s.

Implementation handles n == 32.

Exceptions

  IndexOutOfBoundsException | if `b` is out of bounds, i.e. > 32

Definition at line 59 of file Bitfield.java.

## ◆ isPowerOf2()

static final boolean com.jogamp.common.util.Bitfield.Util.isPowerOf2 | ( | final int | n | ) |

static

Returns `true` if the given integer is a power of 2.

Source: bithacks: http://www.graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2

Definition at line 108 of file Bitfield.java.

Here is the caller graph for this function:

## ◆ nextPowerOf2()

static final int com.jogamp.common.util.Bitfield.Util.nextPowerOf2 | ( | int | n | ) |

static

Returns the next higher power of 2 of 32-bit of given `n @endiliteral.
`

Source: bithacks: http://www.graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2

We rely on the JVM spec `Integer#SIZE` == 32.

Definition at line 120 of file Bitfield.java.

Here is the caller graph for this function:

## ◆ roundToPowerOf2()

static final int com.jogamp.common.util.Bitfield.Util.roundToPowerOf2 | ( | final int | n | ) |

static

If the given `n` is not `isPowerOf2(int)` return `nextPowerOf2(int)`, otherwise return `n` unchanged.

    return isPowerOf2(n) ? n : nextPowerOf2(n);

<p<blockquote>‍

We rely on the JVM spec `Integer#SIZE` == 32.

Definition at line 139 of file Bitfield.java.

Here is the call graph for this function:

## Member Data Documentation

## ◆ MAX_POWER_OF_2

final int com.jogamp.common.util.Bitfield.Util.MAX_POWER_OF_2 = 1 << ( Integer.SIZE - 2 )

static

Maximum 32bit integer value being of `isPowerOf2(int)`.

We rely on the JVM spec `Integer#SIZE` == 32.

Definition at line 50 of file Bitfield.java.

The documentation for this class was generated from the following file:

- src/java/com/jogamp/common/util/Bitfield.java