expanded class interface BIT_N
   -- 
   --  Indexed Bit sequences of length N. This class is a template,
   --  not a real class; to obtain a meaningful class, replace N 
   --  with a positive integer throughout.
   --  
   --  An INTEGER index can be used to access each bit of the sequence.
   --  The leftmost bit has index 1 and the rightmost bit has index N.
   -- 
   --  Note 1 : corresponding C mapping depends on actual N and is 
   --         PLATFORM dependant (see class PLATFORM).
   --         When N is in range [0  .. Character_bits], C type 
   --         is a simple "unsigned char".
   --         When N is in range [Character_bits+1 .. Integer_bits],
   --         C type is "unsigned".
   --         When N is greater than Integer_bits, C type is C array
   --         of "unsigned" of the form :
   --                  "unsigned storage[N div Integer_bits]"
   --         The array is obviously big enough to fit with N. As
   --         for previous mapping, the left most bit (at index 1 in 
   --         Eiffel) is always the left most in C memory.
   -- 
   --  Note 2 : Eiffel BIT code is portable. Generated C code for class
   --         BIT may not be portable (because sizeof(int) may change).
   --         To produce a portable C code, you can compile your Eiffel
   --         code using a machine with very small sizeof(int). Also note
   --         that doing this may run a little bit slowly.
   -- 

feature(s) from BIT_N_REF
   out_in_tagged_out_memory
      --  Append terse printable represention of current object
      --  in tagged_out_memory.


feature(s) from BIT_N_REF
   fill_tagged_out_memory
      --  Append terse printable represention of current object
      --  in tagged_out_memory.


feature(s) from BIT_N
   --  Basic Accessing :

   count: INTEGER
      --  Number of bits in the sequence (the value of N).


   item (idx: INTEGER): BOOLEAN
      --  True if i-th bit is 1, false otherwise.

      require
         inside_bounds: 1 <= idx and then idx <= count

   put (value: BOOLEAN; idx: INTEGER)
      --  Set bit idx to 1 if value is true, 0 otherwise.

      require
         inside_bounds: 1 <= idx and idx <= count
      ensure
         value = item(idx)

   put_1 (idx: INTEGER)
      --  Set bit idx to 1.

      require
         inside_bounds: 1 <= idx and idx <= count
      ensure
         item(idx)

   put_0 (idx: INTEGER)
      --  Set bit idx to 0.

      require
         inside_bounds: 1 <= idx and idx <= count
      ensure
         not item(idx)

feature(s) from BIT_N
   --  Rotating and shifting :

   infix "^" (s: INTEGER): like Current
      --  Sequence shifted by s positions (positive s shifts 
      --  right, negative left; bits falling off the sequence's
      --  bounds are lost).
      --  See also infix "@>>" and infix "@<<".

      require
         s.abs < count

   infix "@>>" (s: INTEGER): like Current
      --  Sequence shifted right by s positions.
      --  Same as infix "^" when s is positive (may run a little 
      --  bit faster).

      require
         s > 0

   infix "@<<" (s: INTEGER): like Current
      --  Sequence shifted left by s positions.
      --  Same as infix "^" when s is negative (may run a little 
      --  bit faster.

      require
         s > 0

   infix "#" (s: INTEGER): like Current
      --  Sequence rotated by s positions (positive right,
      --  negative left).

      require
         s.abs < count

   infix "#>>" (s: INTEGER): like Current
      --  Sequence rotated by s positions right.      

      require
         s >= 0;
         s < count

   infix "#<<" (s: INTEGER): like Current
      --  Sequence rotated by s positions left.      

      require
         s >= 0;
         s < count

feature(s) from BIT_N
   --  Bitwise Logical Operators :

   infix "and" (other: like Current): like Current
      --  Bitwise and of Current with other


   infix "implies" (other: like Current): like Current
      --  Bitwise implication of Current with other


   prefix "not": like Current
      --  Bitwise not of Current.


   infix "or" (other: like Current): like Current
      --  Bitwise or of Current with other


   infix "xor" (other: like Current): like Current
      --  Bitwise xor of Current with other


feature(s) from BIT_N
   --  Conversions :

   to_string: STRING
      --  String representation of bit sequence. 
      --  A zero bit is mapped to '0', a one bit to '1'. 
      --  Leftmost bit is at index 1 in the returned string.
      -- 
      --  Note: see append_in to save memory.

      ensure
         Result.count = count

   to_integer: INTEGER
      --  No sign-extension.

      require
         count <= Integer_bits

   to_character: CHARACTER
      require
         count <= Character_bits

   to_bit_string: BIT_STRING
      ensure
         count = Result.count

feature(s) from BIT_N
   --  Others :

   all_cleared: BOOLEAN
      --  Are all bits set to 0 ?


   all_set: BOOLEAN
      --  Are all bits set to 1 ?


feature(s) from BIT_N
   --  Printing :

   append_in (str: STRING)


end of expanded BIT_N