| Home | Libraries | People | FAQ | More

## Class template integer

boost::histogram::axis::integer — Axis for an interval of integer values with unit steps.

## Synopsis

    // In header: <boost/histogram/axis/integer.hpp>

    template<typename Value, typename MetaData, typename Options>
    class integer : public boost::histogram::axis::iterator_mixin< integer< Value, MetaData, Options > >,
                    public metadata_base_t< MetaData >
    {
    public:

      // public member functions
      integer() = default;
      integer(value_type, value_type, metadata_type = {}, options_type = {});
      integer(const integer &, index_type, index_type, unsigned);
      index_type index(value_type) const noexcept;
      auto update(value_type) noexcept;
      value_type value(local_index_type) const noexcept;
      decltype(auto) bin(index_type) const noexcept;
      index_type size() const noexcept;
      template<typename V, typename M, typename O>
        bool operator==(const integer< V, M, O > &) const noexcept;
      template<typename V, typename M, typename O>
        bool operator!=(const integer< V, M, O > &) const noexcept;
      template<typename Archive> void serialize(Archive &, unsigned);

      // public static functions
      static unsigned options() noexcept;
      static bool inclusive() noexcept;
    };

## Description

Binning is a O(1) operation. This axis bins even faster than a regular axis.

The options `growth` and`circular` are mutually exclusive. If the axis uses integers and either`growth` or`circular` are set, the axis cannot have the options`underflow` or`overflow` set.

### Template Parameters

1.     typename Value

   input value type. Must be integer or floating point.

2.     typename MetaData

   type to store meta data.

3.     typename Options

   see boost::histogram::axis::option.

### `integer` public member functions

1.     integer() = default;

2.     integer(value_type start, value_type stop, metadata_type meta = {},
               options_type options = {});

   Construct over semi-open integer interval [start, stop).

   The constructor throws `std::invalid_argument` if start is not less than stop.

   The arguments meta and alloc are passed by value. If you move either of them into the axis and the constructor throws, their values are lost. Do not move if you cannot guarantee that the bin description is not valid.

   Parameters: |
   `start` | first integer of covered range.
   `stop` | one past last integer of covered range.
   `meta` | description of the axis (optional).
   `options` | see boost::histogram::axis::option (optional).

3.     integer(const integer & src, index_type begin, index_type end, unsigned merge);

   Constructor used by algorithm::reduce to shrink and rebin.

4.     index_type index(value_type x) const noexcept;

   Return index for value argument.

5.     auto update(value_type x) noexcept;

   Returns index and shift (if axis has grown) for the passed argument.

6.     value_type value(local_index_type i) const noexcept;

   Return value for index argument.

7.     decltype(auto) bin(index_type idx) const noexcept;

   Return bin for index argument.

8.     index_type size() const noexcept;

   Returns the number of bins, without over- or underflow.

9.     template<typename V, typename M, typename O>
         bool operator==(const integer< V, M, O > & o) const noexcept;

10.     template<typename V, typename M, typename O>
          bool operator!=(const integer< V, M, O > & o) const noexcept;

11.     template<typename Archive> void serialize(Archive & ar, unsigned);

### `integer` public static functions

1.     static unsigned options() noexcept;

   Returns the options.

2.     static bool inclusive() noexcept;

   Whether the axis is inclusive (see axis::traits::is_inclusive).