#ifndef _GRAY_H_
#define _GRAY_H_

/*! \file gray.h
    \brief Gray code ADT

    Can represent gray codes from 0 - 2^64-1.
 */

typedef long long uint64;

/*! \brief Gray code representation */
struct gray_code {
  uint64 gray_count; /*!< current gray code */
  uint64 bin_count; /*!< corresponding binary representation */
};

/*! \brief Initializes the ADT.
    \param b initial value binary encoded
 */
void gray_init(struct gray_code *c, uint64 b);

/*! \brief Increases the gray count by one.
    \param set to true, if digit changed to 1, else false
    \return the changed digit
 */
int gray_inc(struct gray_code *c, int *state);

/*! \brief Compares two gray codes.
    \return <0, 0, >0, if c < d, c == d, c>d
 */
int gray_compare(struct gray_code *c, struct gray_code *d);

/*! \brief Pretty the ADT.

    I.e. gray code and then binary code.
 */
void gray_print(struct gray_code *c);

/*! \brief Marks an array according to a specified gray code.
    \param length array length
 */
void gray_mark_array(struct gray_code *c, char *array, uint64 length);


#endif
