bool_array::_Element Class Reference


Detailed Description

Class to represent a reference to an array element.

Definition at line 70 of file bool_array.h.


Public Member Functions

 _Element (BYTE *__ptr, unsigned long __idx)
 operator bool () const
bool operator= (bool __value)

Private Attributes

size_t _M_bit_idx
size_t _M_byte_idx
BYTE_M_byte_ptr

Constructor & Destructor Documentation

bool_array::_Element::_Element ( BYTE __ptr,
unsigned long  __idx 
) [inline]

Constructs a reference to an array element.

Parameters:
__ptr pointer to the interal boolean data
__idx index of the array element to access

Definition at line 116 of file bool_array.h.

References _M_bit_idx, _M_byte_idx, and _M_byte_ptr.

00117 {
00118     _M_byte_ptr = __ptr;
00119     _M_byte_idx = (size_t)(__idx / 8);
00120     _M_bit_idx  = (size_t)(__idx % 8);
00121 }


Member Function Documentation

bool_array::_Element::operator bool (  )  const [inline]

Reads the boolean value from an array element.

Returns:
the boolean value of the accessed array element

Definition at line 143 of file bool_array.h.

References _M_bit_idx, _M_byte_idx, and _M_byte_ptr.

00144 {
00145     return *(_M_byte_ptr + _M_byte_idx) & (1 << _M_bit_idx) ? true : false;
00146 }

bool bool_array::_Element::operator= ( bool  __value  )  [inline]

Assigns a new boolean value to an array element.

Parameters:
__value the new boolean value
Returns:
the assigned boolean value

Definition at line 129 of file bool_array.h.

References _M_bit_idx, _M_byte_idx, and _M_byte_ptr.

00130 {
00131     if (__value)
00132         *(_M_byte_ptr + _M_byte_idx) |= 1 << _M_bit_idx;
00133     else
00134         *(_M_byte_ptr + _M_byte_idx) &= ~(1 << _M_bit_idx);
00135     return __value;
00136 }


Field Documentation

Definition at line 79 of file bool_array.h.

Referenced by _Element(), operator bool(), and operator=().

Definition at line 78 of file bool_array.h.

Referenced by _Element(), operator bool(), and operator=().

Definition at line 77 of file bool_array.h.

Referenced by _Element(), operator bool(), and operator=().


The documentation for this class was generated from the following file:

Generated on Wed May 5 00:06:40 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6