Пример #1
0
Node &Node::operator=(const Node &node) {
	if(*this != node) {
		clearElements();
		copyElements(node.children);	
	}

	return *this;
};
Пример #2
0
inline Queue<T> &Queue<T>::operator=(const Queue &other)
{
    if(this != &other)
    {
        clear();
        copyElements(other);
    }
    return *this;
}
Пример #3
0
 void addElement(int x, int y, Element const &value)
 {
     if (innerBox_.containsPoint(IntVector2(x, y))) {
         elements_[getIndex(x, y)] = value;
     } else if (outerBox_.containsPoint(IntVector2(x, y))) {
         innerBox_.mergePoint(IntVector2(x, y));
         elements_[getIndex(x, y)] = value;
     } else {
         normalize();
         
         IntBox2 box(innerBox_);
         box.mergePoint(IntVector2(x, y));
         
         Grid other(box, defaultValue_);
         copyElements(other);
         swap(other);
         
         elements_[getIndex(x, y)] = value;
     }
 }
Пример #4
0
nsresult
txNodeSet::append(const txNodeSet& aNodes)
{
    NS_ASSERTION(mDirection == kForward,
                 "only append(aNode) is supported on reversed nodesets");

    if (aNodes.isEmpty()) {
        return NS_OK;
    }

    PRInt32 appended = aNodes.size();
    if (!ensureGrowSize(appended)) {
        return NS_ERROR_OUT_OF_MEMORY;
    }

    copyElements(mEnd, aNodes.mStart, aNodes.mEnd);
    mEnd += appended;

    return NS_OK;
}
Пример #5
0
void EdifyHacker::copyElements(std::list<EdifyElement*> *src, std::list<EdifyElement*> *dst)
{
    for(std::list<EdifyElement*>::const_iterator itr = src->begin(); itr != src->end(); ++itr)
    {
        switch((*itr)->getType())
        {
            case EDF_VALUE:
                dst->push_back(new EdifyValue(((EdifyValue*)(*itr))->getText()));
                break;
            case EDF_NEWLINE:
                dst->push_back(new EdifyNewline());
                break;
            case EDF_FUNC:
            {
                EdifyFunc *src_f = (EdifyFunc*)(*itr);
                EdifyFunc *dst_f = new EdifyFunc(src_f->getName());
                copyElements(src_f->getArgs(), dst_f->getArgs());
                dst->push_back(dst_f);
                break;
            }
        }
    }
}
Пример #6
0
void BPlusIndexP::moveElements(IndexPage* source, IndexPage* destination, int startIndex, int endIndex) {
	copyElements(source, destination, startIndex, endIndex);
	removeElements(source, startIndex, endIndex);
}
Пример #7
0
void EdifyHacker::saveState()
{
    std::list<EdifyElement*> state;
    copyElements(&m_elements, &state);
    m_savedStates.push_back(state);
}
Пример #8
0
    /**
     * @brief Removes Tuples from the m_Array. If the size of the vector is Zero nothing is done. If the size of the
     * vector is greater than or Equal to the number of Tuples then the m_Array is Resized to Zero. If there are
     * indices that are larger than the size of the original (before erasing operations) then an error code (-100) is
     * returned from the program.
     * @param idxs The indices to remove
     * @return error code.
     */
    virtual int eraseTuples(QVector<size_t>& idxs)
    {

      int err = 0;

      // If nothing is to be erased just return
      if(idxs.size() == 0)
      {
        return 0;
      }
      size_t idxs_size = static_cast<size_t>(idxs.size());
      if (idxs_size >= getNumberOfTuples() )
      {
        resize(0);
        return 0;
      }

      // Sanity Check the Indices in the vector to make sure we are not trying to remove any indices that are
      // off the end of the array and return an error code.
      for(QVector<size_t>::size_type i = 0; i < idxs.size(); ++i)
      {
        if (idxs[i] * m_NumComponents > m_MaxId) { return -100; }
      }

      // Calculate the new size of the array to copy into
      size_t newSize = (getNumberOfTuples() - idxs.size()) * m_NumComponents ;

      // Create a new m_Array to copy into
      T* newArray = (T*)malloc(newSize * sizeof(T));
      // Splat AB across the array so we know if we are copying the values or not
      ::memset(newArray, 0xAB, newSize * sizeof(T));

      // Keep the current Destination Pointer
      T* currentDest = newArray;
      size_t j = 0;
      int k = 0;
      // Find the first chunk to copy by walking the idxs array until we get an
      // index that is NOT a continuous increment from the start
      for (k = 0; k < idxs.size(); ++k)
      {
        if(j == idxs[k])
        {
          ++j;
        }
        else
        {
          break;
        }
      }

      if(k == idxs.size()) // Only front elements are being dropped
      {
        T* currentSrc = m_Array + (j * m_NumComponents);
        ::memcpy(currentDest, currentSrc, (getNumberOfTuples() - idxs.size()) * m_NumComponents * sizeof(T));
        _deallocate(); // We are done copying - delete the current m_Array
        m_Size = newSize;
        m_Array = newArray;
        m_OwnsData = true;
        m_MaxId = newSize - 1;
        m_IsAllocated = true;
        return 0;
      }

      QVector<size_t> srcIdx(idxs.size() + 1);
      QVector<size_t> destIdx(idxs.size() + 1);
      QVector<size_t> copyElements(idxs.size() + 1);
      srcIdx[0] = 0;
      destIdx[0] = 0;
      copyElements[0] = (idxs[0] - 0) * m_NumComponents;

      for (int i = 1; i < srcIdx.size(); ++i)
      {
        srcIdx[i] = (idxs[i - 1] + 1) * m_NumComponents;

        if(i < srcIdx.size() - 1)
        {
          copyElements[i] = (idxs[i] - idxs[i - 1] - 1) * m_NumComponents;
        }
        else
        {
          copyElements[i] = (getNumberOfTuples() - idxs[i - 1] - 1) * m_NumComponents;
        }
        destIdx[i] = copyElements[i - 1] + destIdx[i - 1];
      }

      // Copy the data
      for (int i = 0; i < srcIdx.size(); ++i)
      {
        currentDest = newArray + destIdx[i];
        T* currentSrc = m_Array + srcIdx[i];
        size_t bytes = copyElements[i] * sizeof(T);
        ::memcpy(currentDest, currentSrc, bytes);
      }

      // We are done copying - delete the current m_Array
      _deallocate();

      // Allocation was successful.  Save it.
      m_Size = newSize;
      m_Array = newArray;
      // This object has now allocated its memory and owns it.
      m_OwnsData = true;
      m_IsAllocated = true;
      m_MaxId = newSize - 1;

      return err;
    }
Пример #9
0
 DynamicArrayList::DynamicArrayList(const DynamicArrayList& orig) {
     copyElements(orig);
 }
Пример #10
0
Node::Node(const Node &node) : BaseNode(BaseNode::NODE)
{
	copyElements(node.children);
}