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
701  { // return value at current position plus _Ix
702  return (_Ax[_Base(_Ix)]);
703  }
_Ty _Ax[2 *_Nw]
Definition: random:755
unsigned int _Base(int _Ix=0) const
Definition: random:749
template<class _Ty, size_t _Nw>
unsigned int _Circ_buf< _Ty, _Nw >::_Base ( int  _Ix = 0) const
inline
750  { // return _Ix'th historical element (loosely, (_Idx - _Nw) + _Ix)
751  return ((_Ix += _Idx) < _Nw ? (_Ix + _Nw) : (_Ix - _Nw));
752  }
unsigned int _Idx
Definition: random:754
template<class _Ty, size_t _Nw>
bool _Circ_buf< _Ty, _Nw >::_Equals ( const _Circ_buf< _Ty, _Nw > &  _Right) const
inline
706  { // return true if *this holds same values as _Right
707  const _Ty *_Last1 = _Ax + _Idx;
708  const _Ty *_Last2 = _Right._Ax + _Right._Idx;
709  const _Ty *_First, *_Last, *_Other;
710  bool _Use2 = _Base() < _Right._Base();
711 
712  if (_Use2)
713  { // _Right's range is higher up in the array
714  // than ours, so scan it first
715  _First = _Right._Ax + _Right._Base();
716  _Last = _Last2;
717  _Other = _Ax + _Base();
718  }
719  else
720  { // our range is higher up in the array
721  // than _Right's, so scan ours first
722  _First = _Ax + _Base();
723  _Last = _Last1;
724  _Other = _Right._Ax + _Right._Base();
725  }
726 
727  ptrdiff_t _N0 = _Nw;
728  while (0 < _N0)
729  { // scan
730  // note: may need up to three passes; each scan starts at the
731  // current highest array position and ends at the end of the
732  // array or the _Idx value, whichever comes first; the
733  // equality test succeeds only by reaching the _Idx value.
734  const _Ty *_Limit = _First < _Last ? _Last
735  : _Use2 ? _Right._Ax + 2 * _Nw
736  : _Ax + 2 * _Nw;
737  _N0 -= _Limit - _First;
738  while (_First != _Limit)
739  if (*_First++ != *_Other++)
740  return (false);
741  _First = _Other;
742  _Last = _Use2 ? _Last1 : _Last2;
743  _Other = _Use2 ? _Right._Ax : _Ax;
744  _Use2 = !_Use2;
745  }
746  return (true);
747  }
unsigned int _Idx
Definition: random:754
_Ty _Ax[2 *_Nw]
Definition: random:755
int ptrdiff_t
Definition: vcruntime.h:199
unsigned int _Base(int _Ix=0) const
Definition: random:749
_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: