예제 #1
0
	GeneralListNode* _Copy(GeneralListNode* head) const
	{
		GeneralListNode* newHead = new GeneralListNode(HEAD_TYPE);

		GeneralListNode* prev = newHead;
		GeneralListNode* begin = head->_next;
		while (begin)
		{
			GeneralListNode* cur = new GeneralListNode();

			if(begin->_type == HEAD_TYPE)
			{
				cur->_type = HEAD_TYPE;
			}
			else if (begin->_type == SUB_TYPE)
			{
				cur->_type = SUB_TYPE;
				cur->_subLink = _Copy(begin->_subLink);
			}
			else
			{
				cur->_type = VALUE_TYPE;
				cur->_value = begin->_value;
			}

			prev->_next = cur;
			prev = cur;

			begin = begin->_next;
		}

		return newHead;
	}
예제 #2
0
void C_vector_any::_PushBack(const void *val){

   if(used_size == res_size){
      res_size = Max(1ul, res_size+grow_size);
      byte *new_a = new(true) byte[res_size*elem_size];
      MemCpy(new_a, array, used_size*elem_size);
      delete[] array;
      array = new_a;
   }
   void *ptr = _End();
   _Construct(ptr);
   _Copy(ptr, val);
   ++used_size;
}
예제 #3
0
void C_vector_any::_CopyVector(const C_vector_any &v){

   if(this==&v)
      return;
   _Clear();
   int i = v.used_size;
   _Reserve(i);
   used_size = i;
   while(i--){
      int offs = i*elem_size;
      _Construct(array+offs);
      _Copy(array+offs, v.array + offs);
   }
}
예제 #4
0
void C_vector_any::_Insert(dword dst_i, const void *src, dword num){

   if(!num)
      return;
   assert(dst_i <= (dword)used_size);
   _Reserve(used_size+num);

   used_size += num;
   for(int i=used_size-num-dst_i; i--; )
      MemCpy(_At(dst_i+num+i), _At(dst_i+i), elem_size);

   byte *dst = (byte*)_At(dst_i);
   for(dword i=0; i<num; i++, dst += elem_size, src = (byte*)src+elem_size){
      _Construct(dst);
      _Copy(dst, src);
   }
}
예제 #5
0
	void StrBase<XChar>::ToLower(void)
{
	AssertObj(this);

	if (!m_pbuf->Cch())
		return;

	// If this string object is sharing a buffer, then you must not change the other string
	// sharing the buffer. Rather, copy it.
	if (m_pbuf->m_crefMinusOne > 0)
		_Copy();

	AssertObj(m_pbuf);
	Assert(m_pbuf->m_crefMinusOne == 0);
	gr::ToLower(m_pbuf->m_rgch, m_pbuf->Cch());

	AssertObj(this);
}
예제 #6
0
	void StrBase<XChar>::SetAt(int ich, XChar ch)
{
	AssertObj(this);
	Assert(ich >= 0);
	Assert((unsigned int)ich < (unsigned int)m_pbuf->Cch());

	// If ch is the same as the character already at ich, return.
	if (ch == m_pbuf->m_rgch[ich])
		return;

	// If this string object is sharing a buffer, then you must not change the other string
	// sharing the buffer.  Rather, copy it.
	if (m_pbuf->m_crefMinusOne > 0)
		_Copy();

	AssertObj(m_pbuf);
	Assert(m_pbuf->m_crefMinusOne == 0);
	m_pbuf->m_rgch[ich] = ch;

	AssertObj(this);
}
예제 #7
0
	GeneralListNode* _Copy(GeneralListNode* head)
	{
		GeneralListNode* cur = head->_next;
		GeneralListNode* newHead = new GeneralListNode(HEAD);
		while (cur)
		{
			if (cur->_type == VALUE)//若为值,连接在新表头的后边
			{
				GeneralListNode* newCur = newHead;
				newCur->_next = new GeneralListNode(VALUE, cur->_value);
				newCur = newCur->_next;
			}
			else if (cur->_type == SUB)//若为子表
			{
				GeneralListNode* newCur = newHead;
				newCur->_next = new GeneralListNode(SUB);
				newCur = newCur->_next;
				newCur->_subLink = _Copy(cur->_subLink);//递归
			}
			cur = cur->_next;
		}
		return newHead;
	}
예제 #8
0
KyRefHandle& KyRefHandle::operator =(const KyRefHandle& other)
{
    _Copy(other);
    return (*this);
}
예제 #9
0
KyRefHandle::KyRefHandle(const KyRefHandle& other)
{
    _Copy(other);
}
예제 #10
0
	GeneralListNode* Copy() const
	{
		return _Copy(_head);
	}
예제 #11
0
	GeneralList(const GeneralList& g)//拷贝构造
	{
		_head = _Copy(g._head);
	}