STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Public Attributes | List of all members
_Circ_buf< _Ty, _Nw > Struct Template Reference

Public Member Functions

_Ty _At (int _Ix) const
 
bool _Equals (const _Circ_buf &_Right) const
 
unsigned int _Base (int _Ix=0) const
 

Public Attributes

unsigned int _Idx
 
_Ty _Ax [2 *_Nw]
 

Member Function Documentation

template<class _Ty, size_t _Nw>
_Ty _Circ_buf< _Ty, _Nw >::_At ( int  _Ix) const
inline
678  { // return value at current position plus _Ix
679  return (_Ax[_Base(_Ix)]);
680  }
_Ty _Ax[2 *_Nw]
Definition: random:732
unsigned int _Base(int _Ix=0) const
Definition: random:726
template<class _Ty, size_t _Nw>
unsigned int _Circ_buf< _Ty, _Nw >::_Base ( int  _Ix = 0) const
inline
727  { // return _Ix'th historical element (loosely, (_Idx - _Nw) + _Ix)
728  return ((_Ix += _Idx) < _Nw ? (_Ix + _Nw) : (_Ix - _Nw));
729  }
unsigned int _Idx
Definition: random:731
template<class _Ty, size_t _Nw>
bool _Circ_buf< _Ty, _Nw >::_Equals ( const _Circ_buf< _Ty, _Nw > &  _Right) const
inline
683  { // return true if *this holds same values as _Right
684  const _Ty *_Last1 = _Ax + _Idx;
685  const _Ty *_Last2 = _Right._Ax + _Right._Idx;
686  const _Ty *_First, *_Last, *_Other;
687  bool _Use2 = _Base() < _Right._Base();
688 
689  if (_Use2)
690  { // _Right's range is higher up in the array
691  // than ours, so scan it first
692  _First = _Right._Ax + _Right._Base();
693  _Last = _Last2;
694  _Other = _Ax + _Base();
695  }
696  else
697  { // our range is higher up in the array
698  // than _Right's, so scan ours first
699  _First = _Ax + _Base();
700  _Last = _Last1;
701  _Other = _Right._Ax + _Right._Base();
702  }
703 
704  ptrdiff_t _N0 = _Nw;
705  while (0 < _N0)
706  { // scan
707  // note: may need up to three passes; each scan starts at the
708  // current highest array position and ends at the end of the
709  // array or the _Idx value, whichever comes first; the
710  // equality test succeeds only by reaching the _Idx value.
711  const _Ty *_Limit = _First < _Last ? _Last
712  : _Use2 ? _Right._Ax + 2 * _Nw
713  : _Ax + 2 * _Nw;
714  _N0 -= _Limit - _First;
715  while (_First != _Limit)
716  if (*_First++ != *_Other++)
717  return (false);
718  _First = _Other;
719  _Last = _Use2 ? _Last1 : _Last2;
720  _Other = _Use2 ? _Right._Ax : _Ax;
721  _Use2 = !_Use2;
722  }
723  return (true);
724  }
unsigned int _Idx
Definition: random:731
_Ty _Ax[2 *_Nw]
Definition: random:732
int ptrdiff_t
Definition: vcruntime.h:199
unsigned int _Base(int _Ix=0) const
Definition: random:726
_FwdIt _Last
Definition: algorithm:1936

Member Data Documentation

template<class _Ty, size_t _Nw>
_Ty _Circ_buf< _Ty, _Nw >::_Ax[2 *_Nw]
template<class _Ty, size_t _Nw>
unsigned int _Circ_buf< _Ty, _Nw >::_Idx

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