|
SoftNet-Consult Java Utility Library | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.softnetConsult.utils.math.BitmapTools
public final class BitmapTools
This class provides implementations for various bit-level operations of Java types that can be used as bit-maps.
This product includes software developed by the
SoftNet-Consult Java Utility Library project and its contributors.
(http://java-tools.sourceforge.net)
Copyright (c) 2007-2008 SoftNet-Consult.
Copyright (c) 2007-2008 G. Paperin.
All rights reserved.
File: BitmapTools.java
Library API version: "2.02"
Java compliance version: "1.5"
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following terms and conditions are met:
1. Redistributions of source code must retain the above
acknowledgement of the SoftNet-Consult Java Utility Library project, the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above acknowledgement of the
SoftNet-Consult Java Utility Library project, the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
3. All advertising materials mentioning features or use of this software or any derived
software must display the following acknowledgement:
This product includes software developed by the SoftNet-Consult Java Utility Library
project and its contributors.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Constructor Summary | |
---|---|
private |
BitmapTools()
Prevents instances of this class from being created as this class contains only static utility methods. |
Method Summary | |
---|---|
static boolean |
checkBit(byte val,
int bitNum)
Checks the state of a specified bit in the specified bit-map. |
static boolean |
checkBit(int val,
int bitNum)
Checks the state of a specified bit in the specified bit-map. |
static boolean |
checkBit(long val,
int bitNum)
Checks the state of a specified bit in the specified bit-map. |
static boolean |
checkBit(short val,
int bitNum)
Checks the state of a specified bit in the specified bit-map. |
static byte |
clearBit(byte val,
int bitNum)
Clears a specified bit in the specified bit-map to 0. |
static int |
clearBit(int val,
int bitNum)
Clears a specified bit in the specified bit-map to 0. |
static long |
clearBit(long val,
int bitNum)
Clears a specified bit in the specified bit-map to 0. |
static short |
clearBit(short val,
int bitNum)
Clears a specified bit in the specified bit-map to 0. |
static int |
hammingDistance(boolean[] a,
boolean[] b)
Computes the hamming distance between two boolean arrays of the same length. |
static int |
hammingDistance(boolean[] a,
int offsA,
boolean[] b,
int offsB,
int len)
Computes the hamming distance between specified sections of two boolean arrays. |
static int |
hammingDistance(int a,
int b)
Computes the haming distance between the bit-patterns that represent a
and b . |
static int |
hammingDistance(int a,
int b,
int len)
Computes the haming distance between the bit-patterns that represent a
and b , only len rightmost bits are considered. |
static int |
hammingDistance(long a,
long b)
Computes the haming distance between the bit-patterns that represent a
and b . |
static int |
hammingDistance(long a,
long b,
int len)
Computes the haming distance between the bit-patterns that represent a
and b , only len rightmost bits are considered. |
static byte |
setBit(byte val,
int bitNum)
Sets a specified bit in the specified bit-map to 1. |
static int |
setBit(int val,
int bitNum)
Sets a specified bit in the specified bit-map to 1. |
static long |
setBit(long val,
int bitNum)
Sets a specified bit in the specified bit-map to 1. |
static short |
setBit(short val,
int bitNum)
Sets a specified bit in the specified bit-map to 1. |
static byte |
toggleBit(byte val,
int bitNum)
Toggles a specified bit in the specified bit-map from 1 to 0 or from 0 to 1 respectively. |
static int |
toggleBit(int val,
int bitNum)
Toggles a specified bit in the specified bit-map from 1 to 0 or from 0 to 1 respectively. |
static long |
toggleBit(long val,
int bitNum)
Toggles a specified bit in the specified bit-map from 1 to 0 or from 0 to 1 respectively. |
static short |
toggleBit(short val,
int bitNum)
Toggles a specified bit in the specified bit-map from 1 to 0 or from 0 to 1 respectively. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private BitmapTools()
Method Detail |
---|
public static int hammingDistance(int a, int b, int len)
a
and b
, only len
rightmost bits are considered.
a
- Some bit-pattern.b
- Some bit-pattern.len
- Number of rightmost bits to consider (0 to 32).
public static int hammingDistance(int a, int b)
a
and b
.
a
- Some bit-pattern.b
- Some bit-pattern.
public static int hammingDistance(long a, long b, int len)
a
and b
, only len
rightmost bits are considered.
a
- Some bit-pattern.b
- Some bit-pattern.len
- Number of rightmost bits to consider (0 to 64).
public static int hammingDistance(long a, long b)
a
and b
.
a
- Some bit-pattern.b
- Some bit-pattern.
public static int hammingDistance(boolean[] a, boolean[] b)
a
- A non-null array.b
- A non-null array.
java.lang.NullPointerException
- if a null reference was passed.
java.lang.IllegalArgumentException
- if the specified arrays have different lengths.public static int hammingDistance(boolean[] a, int offsA, boolean[] b, int offsB, int len)
a
- A non-null array.offsA
- The position from which to start comparison in array a
(from left).b
- A non-null array.offsB
- The position from which to start comparison in array b
(from left).len
- The number of positions to compare.
java.lang.NullPointerException
- if a null reference was passed.
java.lang.IllegalArgumentException
- if any of the specified intervals does not fit the corresponding array.public static byte setBit(byte val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to set (rightmost bit has index 0).
public static short setBit(short val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to set (rightmost bit has index 0).
public static int setBit(int val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to set (rightmost bit has index 0).
public static long setBit(long val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to set (rightmost bit has index 0).
public static byte clearBit(byte val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to clear (rightmost bit has index 0).
public static short clearBit(short val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to clear (rightmost bit has index 0).
public static int clearBit(int val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to clear (rightmost bit has index 0).
public static long clearBit(long val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to clear (rightmost bit has index 0).
public static byte toggleBit(byte val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
public static short toggleBit(short val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
public static int toggleBit(int val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
public static long toggleBit(long val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
public static boolean checkBit(byte val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
true
if the specified bit is 1
;
false
if the specified bit is 0
.public static boolean checkBit(short val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
true
if the specified bit is 1
;
false
if the specified bit is 0
.public static boolean checkBit(int val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
true
if the specified bit is 1
;
false
if the specified bit is 0
.public static boolean checkBit(long val, int bitNum)
val
- A bit-map.bitNum
- The index of the bit to toggle (rightmost bit has index 0).
true
if the specified bit is 1
;
false
if the specified bit is 0
.
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |