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
724  { // return value at current position plus _Ix
725  return (_Ax[_Base(_Ix)]);
726  }
_Ty _Ax[2 *_Nw]
Definition: random:778
unsigned int _Base(int _Ix=0) const
Definition: random:772
template<class _Ty, size_t _Nw>
unsigned int _Circ_buf< _Ty, _Nw >::_Base ( int  _Ix = 0) const
inline
773  { // return _Ix'th historical element (loosely, (_Idx - _Nw) + _Ix)
774  return ((_Ix += _Idx) < _Nw ? (_Ix + _Nw) : (_Ix - _Nw));
775  }
unsigned int _Idx
Definition: random:777
template<class _Ty, size_t _Nw>
bool _Circ_buf< _Ty, _Nw >::_Equals ( const _Circ_buf< _Ty, _Nw > &  _Right) const
inline
729  { // return true if *this holds same values as _Right
730  const _Ty *_Last1 = _Ax + _Idx;
731  const _Ty *_Last2 = _Right._Ax + _Right._Idx;
732  const _Ty *_First, *_Last, *_Other;
733  bool _Use2 = _Base() < _Right._Base();
734 
735  if (_Use2)
736  { // _Right's range is higher up in the array
737  // than ours, so scan it first
738  _First = _Right._Ax + _Right._Base();
739  _Last = _Last2;
740  _Other = _Ax + _Base();
741  }
742  else
743  { // our range is higher up in the array
744  // than _Right's, so scan ours first
745  _First = _Ax + _Base();
746  _Last = _Last1;
747  _Other = _Right._Ax + _Right._Base();
748  }
749 
750  ptrdiff_t _N0 = _Nw;
751  while (0 < _N0)
752  { // scan
753  // note: may need up to three passes; each scan starts at the
754  // current highest array position and ends at the end of the
755  // array or the _Idx value, whichever comes first; the
756  // equality test succeeds only by reaching the _Idx value.
757  const _Ty *_Limit = _First < _Last ? _Last
758  : _Use2 ? _Right._Ax + 2 * _Nw
759  : _Ax + 2 * _Nw;
760  _N0 -= _Limit - _First;
761  while (_First != _Limit)
762  if (*_First++ != *_Other++)
763  return (false);
764  _First = _Other;
765  _Last = _Use2 ? _Last1 : _Last2;
766  _Other = _Use2 ? _Right._Ax : _Ax;
767  _Use2 = !_Use2;
768  }
769  return (true);
770  }
unsigned int _Idx
Definition: random:777
_Ty _Ax[2 *_Nw]
Definition: random:778
_W64 int ptrdiff_t
Definition: crtdefs.h:530
unsigned int _Base(int _Ix=0) const
Definition: random:772
_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: