Added more javadoc

git-svn-id: https://zxing.googlecode.com/svn/trunk@9 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2007-11-06 18:56:30 +00:00
parent abf5a2cac4
commit f44627915e
5 changed files with 72 additions and 14 deletions

View file

@ -34,6 +34,7 @@ public final class BitArray {
}
/**
* @param i bit to get
* @return true iff bit i is set
*/
public boolean get(int i) {
@ -42,17 +43,26 @@ public final class BitArray {
/**
* Sets bit i.
*
* @param i bit to set
*/
public void set(int i) {
bits[i >> 5] |= 1 << (i & 0x1F);
}
/**
* Sets a block of 32 bits, starting at bit i.
*
* @param i first bit to set
* @param newBits the new value of the next 32 bits. Note again that the least-significant bit
* correponds to bit i, the next-least-significant to i+1, and so on.
*/
public void setBulk(int i, int newBits) {
bits[i >> 5] = newBits;
}
/**
* Clears all bits.
* Clears all bits (sets to false).
*/
public void clear() {
int max = bits.length;

View file

@ -50,16 +50,35 @@ public final class BitMatrix {
bits = new int[arraySize];
}
/**
* @param i row offset
* @param j column offset
* @return value of given bit in matrix
*/
public boolean get(int i, int j) {
int offset = i + dimension * j;
return ((bits[offset >> 5] >>> (offset & 0x1F)) & 0x01) != 0;
}
/**
* <p>Sets the given bit to true.</p>
*
* @param i row offset
* @param j column offset
*/
public void set(int i, int j) {
int offset = i + dimension * j;
bits[offset >> 5] |= 1 << (offset & 0x1F);
}
/**
* <p>Sets a square region of the bit matrix to true.</p>
*
* @param topI row offset of region's top-left corner (inclusive)
* @param leftJ column offset of region's top-left corner (inclusive)
* @param height height of region
* @param width width of region
*/
public void setRegion(int topI, int leftJ, int height, int width) {
if (topI < 0 || leftJ < 0) {
throw new IllegalArgumentException("topI and leftJ must be nonnegative");
@ -82,25 +101,30 @@ public final class BitMatrix {
}
}
/**
* @return row/column dimension of this matrix
*/
public int getDimension() {
return dimension;
}
/**
* @return array of ints holding internal representation of this matrix's bits
*/
public int[] getBits() {
return bits;
}
/*
public BufferedImage toBufferedImage() {
BufferedImage image =
new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY);
for (int j = 0; j < dimension; j++) {
for (int i = 0; i < dimension; i++) {
image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF);
}
}
return image;
}
*/
BufferedImage image = new BufferedImage(dimension, dimension, BufferedImage.TYPE_BYTE_BINARY);
for (int j = 0; j < dimension; j++) {
for (int i = 0; i < dimension; i++) {
image.setRGB(j, i, get(i, j) ? 0x00000000 : 0x00FFFFFF);
}
}
return image;
}
*/
}

View file

@ -30,8 +30,8 @@ public final class Collections {
* Sorts its argument (destructively) using insert sort; in the context of this package
* insertion sort is simple and efficient given its relatively small inputs.
*
* @param vector
* @param comparator
* @param vector vector to sort
* @param comparator comparator to define sort ordering
*/
public static void insertionSort(Vector vector, Comparator comparator) {
int max = vector.size();

View file

@ -51,16 +51,24 @@ final class GF256 {
}
/**
* Addition and subtraction are the same in GF(256).
* Implements both addition and subtraction -- they are the same in GF(256).
*
* @return sum/difference of a and b
*/
static int addOrSubtract(int a, int b) {
return a ^ b;
}
/**
* @return 2 to the power of a in GF(256)
*/
static int exp(int a) {
return exp[a];
}
/**
* @return base 2 log of a in GF(256)
*/
static int log(int a) {
if (a == 0) {
throw new IllegalArgumentException();
@ -78,6 +86,12 @@ final class GF256 {
return exp[255 - log[a]];
}
/**
*
* @param a
* @param b
* @return product of a and b in GF(256)
*/
static int multiply(int a, int b) {
if (a == 0 || b == 0) {
return 0;

View file

@ -37,12 +37,22 @@ import java.util.Vector;
* port of his C++ Reed-Solomon implementation.</p>
*
* @author srowen@google.com (Sean Owen)
* @author William Rucklidge
*/
public final class ReedSolomonDecoder {
private ReedSolomonDecoder() {
}
/**
* <p>Decodes given set of received codewords, which include both data and error-correction
* codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place,
* in the input.</p>
*
* @param received data and error-correction codewords
* @param twoS number of error-correction codewords available
* @throws ReedSolomonException if decoding fails for any reaosn
*/
public static void decode(int[] received, int twoS) throws ReedSolomonException {
GF256Poly poly = new GF256Poly(received);
int[] syndromeCoefficients = new int[twoS];