int __delete(int root, int val) { if (A[root].val == -1) return 0; if (val < A[root].val) { A[root].left = __delete(A[root].left, val); } else if (val > A[root].val) { A[root].right = __delete(A[root].right, val); } else { if (A[root].left) { for (leaf = A[root].left; A[leaf].right; leaf = A[leaf].right); A[root].left = __delete(A[root].left, A[leaf].val); A[root].val = A[leaf].val; } else if (A[root].right) { for (leaf = A[root].right; A[leaf].left; leaf = A[leaf].left); A[root].right = __delete(A[root].right, A[leaf].val); A[root].val = A[leaf].val; } else { leaf = root; return 0; } } if (A[A[root].left].lvl <= A[root].lvl - 2 || A[A[root].right].lvl <= A[root].lvl - 2) { --A[root].lvl; if (A[A[root].right].lvl > A[root].lvl) A[A[root].right].lvl = A[root].lvl; root = skew(root); A[root].right = skew(A[root].right); A[A[root].right].right = skew(A[A[root].right].right); root = split(root); A[root].right = split(A[root].right); return root; } return root; }
/** * Destructor. */ virtual ~GridBuffer() { for (uint32_t i = 0; i < 27; ++i) { __delete(sendExchanges[i]); __delete(receiveExchanges[i]); } __delete(hostBuffer); __delete(deviceBuffer); }
void operator()(ThreadParams& params, const std::string& name, T_Scalar* value, const std::string& attrName = "", T_Attribute* attribute = nullptr) { log<picLog::INPUT_OUTPUT>("HDF5: read %1%D scalars: %2%") % simDim % name; Dimensions domain_offset(0, 0, 0); for (uint32_t d = 0; d < simDim; ++d) domain_offset[d] = Environment<simDim>::get().GridController().getPosition()[d]; // avoid deadlock between not finished pmacc tasks and mpi calls in adios __getTransactionEvent().waitForFinished(); DomainCollector::DomDataClass data_class; DataContainer *dataContainer = params.dataCollector->readDomain(params.currentStep, name.c_str(), Domain(domain_offset, Dimensions(1, 1, 1)), &data_class); typename traits::PICToSplash<T_Scalar>::type splashType; *value = *static_cast<T_Scalar*>(dataContainer->getIndex(0)->getData()); __delete(dataContainer); if(!attrName.empty()) { log<picLog::INPUT_OUTPUT>("HDF5: read attribute %1% for scalars: %2%") % attrName % name; params.dataCollector->readAttributeInfo(params.currentStep, name.c_str(), attrName.c_str()).read(attribute, sizeof(T_Attribute)); log<picLog::INPUT_OUTPUT>("HDF5: attribute %1% = %2%") % attrName % *attribute; } }
void PatchReader::checkSpatialTypeSize( splash::DataCollector* const dc, const uint32_t availableRanks, const int32_t id, const std::string particlePatchPathComponent ) const { // will later read into 1D buffer from first position on splash::Dimensions dstBuffer(availableRanks, 1, 1); splash::Dimensions dstOffset(0, 0, 0); // sizeRead will be set splash::Dimensions sizeRead(0, 0, 0); splash::CollectionType* colType = dc->readMeta( id, particlePatchPathComponent.c_str(), dstBuffer, dstOffset, sizeRead ); // check if the 1D list of patches has the right length assert( sizeRead[0] == availableRanks ); // currently only support uint64_t types to spare type conversation assert( typeid(*colType) == typeid(splash::ColTypeUInt64) ); // free collections __delete( colType ); }
owned_ptr& operator=(const owned_ptr& rhs) { if(this != &rhs) { if(get() != rhs.get()) { __delete(); } _ptr = rhs._ptr; rhs.release(); } return *this; }
static void z_object_virtual_dispose(Self *self) { set_closure_marshal(self, NULL); cleanup_attached_properties(self); ZMap *signal_map = (ZMap *) selfp->signal_map; if (signal_map) { unref(Z_OBJECT(signal_map)); selfp->signal_map = NULL; } __delete(self); }
/** * Destructor. * Deletes internal streams. Tears down CUDA. */ virtual ~StreamController() { for (size_t i = 0; i < streams.size(); i++) { __delete(streams[i]); } streams.clear(); /* This is the single point in PIC where ALL CUDA work must be finished. */ /* Accessing CUDA objects after this point may fail! */ CUDA_CHECK_NO_EXCEPT(cudaDeviceSynchronize()); CUDA_CHECK_NO_EXCEPT(cudaDeviceReset()); }
void absent_packet_list::erase(const iterator& itr, bool inRequestingState) { seqno_t seqno = *itr; BOOST_ASSERT(itr == find(seqno, inRequestingState)); if (inRequestingState) requesting_packets_.erase(itr); else not_requesting_packets_.erase(itr); BOOST_ASSERT(!find(seqno)); __delete(seqno); if (seqno_less(seqno, get_client_param_sptr()->smallest_seqno_absenct)) { if (!empty()) get_client_param_sptr()->smallest_seqno_absenct = min_seqno(); } }
void absent_packet_list::erase(seqno_t seqno) { BOOST_AUTO(itr, not_requesting_packets_.find(seqno)); if (itr != not_requesting_packets_.end()) { erase(itr, false); } else if ((itr = requesting_packets_.find(seqno)) != requesting_packets_.end()) { erase(itr, true); } else { BOOST_AUTO(&pktInfoPtr, get_slot(media_packet_info_vector_, seqno)); if (pktInfoPtr&&pktInfoPtr->is_this(seqno, timestamp_now())) { __delete(seqno); } } BOOST_ASSERT(!find(seqno)); }
return root; } return root; } int fixPointer(int root, int val, int leaf) { if (A[root].val == -1) return 0; if (A[root].val == val) return leaf; if (val < A[root].val) A[root].left = fixPointer(A[root].left, val, leaf); else A[root].right = fixPointer(A[root].right, val, leaf); return root; } void delete(int val) { leaf = 0; R = __delete(R, val); // the following reuses space, but not necessary for this // homework since the array is large enough. if (leaf) { if (leaf != N-1) { // leaf == N-1 is possible R = fixPointer(R, A[N-1].val, leaf); A[leaf] = A[N-1]; } --N; } } int main() { init(); scanf("%d6", &M);
BOOST_FOREACH(const seqno_t seqno, requesting_packets_) { __delete(seqno); }
virtual ~ExchangeIntern() { __delete(hostBuffer); __delete(deviceBuffer); __delete(deviceDoubleBuffer); }
/** * Destructor */ virtual ~HeapBuffer() { __delete(ringBuffer); }
void finalize() { gather.finalize(); __delete(buff1); __delete(buff2); }
~owned_ptr() { __delete(); }
virtual ~Reduce() { __delete(reduceBuffer); }
void operator()(T_StorageTuple& tuple) { __delete(tuple[SpeciesName()]); }
void absent_packet_list::clear() { BOOST_FOREACH(const seqno_t seqno, not_requesting_packets_) { __delete(seqno); }