예제 #1
0
int PtrDynArray<T>::Compare(const PtrDynArray<T>& Arr_) const
{
  if (_CompFunc && (RunLength() == Arr_.RunLength()))
  {
    size_t x, Max_;
    int Result_ = 0;
    
    for (x = 0, Max_ = RunLength(); x < Max_ && !Result_; x++)
      Result_ = (*_CompFunc)((*this)[x], Arr_[x]);

    return Result_;
  }

  _Xran();
  return 0;
}
예제 #2
0
파일: STRINX.CPP 프로젝트: hkaiser/TRiAS
// insert a substring into a string
string &string :: insert (size_t p0, const string &str, size_t pos, size_t ns)
{
	if (m_iLen < p0 || str.length() < pos) _Xran();
	
size_t n = str.length() - pos;

	if ( n < ns) ns = n;
	if (NPOS - m_iLen <= ns) _Xlen();

	if (0 < ns && _Grow (n = m_iLen + ns)) {
	// insert to make non-empty string
		memmove (m_pPtr + p0 + ns, m_pPtr + p0, m_iLen - p0);
		memcpy (m_pPtr + p0, &str.c_str()[pos], ns);
		m_pPtr[m_iLen = n] = '\0';
	}
	
return (*this);
}
예제 #3
0
파일: STRREX.CPP 프로젝트: hkaiser/TRiAS
// replace with a repeated char in a string
string &string :: replace (size_t p0, size_t n0, const string &str, 
			   size_t pos, size_t ns)
{
	if (m_iLen < p0 || str.length() < pos) _Xran();
	
size_t n = str.length() - pos;

	if (n < ns) ns = n;
	if (NPOS - ns <= m_iLen - n0) _Xlen();

size_t nm = m_iLen - n0 - p0;
	
	if (ns < n0)
		memmove (m_pPtr + p0 + ns, m_pPtr + p0 + n0, nm);
	if ((0 < ns || 0 < n0) && _Grow (n = m_iLen + ns - n0)) {
	// replace to make non-empty string
		if (n0 < ns)
			memmove (m_pPtr + p0 + ns, m_pPtr + p0 + n0, nm);
		memcpy (m_pPtr + p0, &str.c_str()[pos], ns);
		m_pPtr[m_iLen = n] = '\0';
	}
	
return (*this);
}
	reference at(size_type _Pos)
		{	// subscript mutable sequence with checking
		if (size() <= _Pos)
			_Xran();
		return (*(this->_Myfirst + _Pos));
		}