package com.srbenoit.math.linear;

/**
 * A labeled bit number used to store flags associated with matrix elements.
 */
public enum MatrixElementFlag {

    /** bit number for a 'completed' flag */
    COMPLETED(0),

    /** bit number for a 'in-progress' flag */
    IN_PROGRESS(1),

    /** bit number for a 'out-of-range' flag */
    OUT_OF_RANGE(2),

    /** bit number for a 'tagged' flag */
    TAGGED(3);

    /** the bit used to store this flag */
    private final int flagBit;

    /**
     * Constructs a new <code>MatrixElementFlag</code>.
     *
     * @param  whichBit  the bit used to store this flag (0-7)
     */
    private MatrixElementFlag(final int whichBit) {

        this.flagBit = whichBit;
    }

    /**
     * Gets the bit used to store this flag.
     *
     * @return  the bit used to store this flag (0-7)
     */
    public int flagBit() {

        return this.flagBit;
    }

    /**
     * Generates the mask byte (a byte with a single bit set) for a particular flag.
     *
     * @return  the mask byte
     */
    public byte toMask() {

        return (byte) (0x01 << this.flagBit);
    }
}
