bool CIntervalTree::DoDelete(TTreeNode* node, const interval_type& interval, TTreeMapI value) { _ASSERT(node); coordinate_type key = node->m_Key; if ( interval.GetFrom() > key ) { // left return DoDelete(node->m_Right, interval, value) && !node->m_NodeIntervals && !node->m_Left; } else if ( interval.GetTo() < key ) { // right return DoDelete(node->m_Left, interval, value) && !node->m_NodeIntervals && !node->m_Right; } else { // inside TTreeNodeInts* nodeIntervals = node->m_NodeIntervals; _ASSERT(nodeIntervals); if ( !nodeIntervals->Delete(interval, value) ) return false; // node intervals non empty // remove node intervals DeleteNodeIntervals(nodeIntervals); node->m_NodeIntervals = 0; // delete node if it doesn't have leaves return !node->m_Left && !node->m_Right; } }
/************************************************************************** * ISvItemCm_fnInvokeCommand() */ static HRESULT WINAPI ISvItemCm_fnInvokeCommand( IContextMenu *iface, LPCMINVOKECOMMANDINFO lpcmi) { ICOM_THIS(ItemCmImpl, iface); TRACE("(%p)->(invcom=%p verb=%p wnd=%x)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); if(LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST) return E_INVALIDARG; switch(LOWORD(lpcmi->lpVerb)) { case FCIDM_SHVIEW_EXPLORE: DoOpenExplore(iface, lpcmi->hwnd, "explore"); break; case FCIDM_SHVIEW_OPEN: DoOpenExplore(iface, lpcmi->hwnd, "open"); break; case FCIDM_SHVIEW_RENAME: DoRename(iface, lpcmi->hwnd); break; case FCIDM_SHVIEW_DELETE: DoDelete(iface); break; case FCIDM_SHVIEW_COPY: DoCopyOrCut(iface, lpcmi->hwnd, FALSE); break; case FCIDM_SHVIEW_CUT: DoCopyOrCut(iface, lpcmi->hwnd, TRUE); break; } return NOERROR; }
size_t Storage::RemoveExpired(const StreamIndicator& baseIndicator, UINT minBufferTime) { UINT64 elapsedTime = baseIndicator.GetElapsedTime(); LIVE_ASSERT(elapsedTime <= INT_MAX); if (elapsedTime <= minBufferTime) { return 0; } elapsedTime -= minBufferTime; size_t deletedCount = 0; PieceInfoCollection::iterator iter = m_dataPieces.begin(); while (iter != m_dataPieces.end()) { if (m_dataPieces.size() <= 1) break; MediaDataPiecePtr piece = iter->second.GetPiece(); CheckDataPiece(piece); UINT pieceIndex = iter->first; // 可能删掉upperBound对应的piece //LIVE_ASSERT(pieceIndex < upperBound); // 如果upperBound以后一直没有数据,或者距离很远才遇到下一片,则可能会发生upperBound对应的片也过时的情况 if (pieceIndex >= baseIndicator.GetPieceIndex()) { // peer端的BaseIndex不一定是最小的,需要加以检查 LIVE_ASSERT( piece->GetTimeStamp() >= baseIndicator.GetTimeStamp() ); UINT64 elapsedTimeStamp = piece->GetTimeStamp() - baseIndicator.GetTimeStamp(); if (elapsedTimeStamp >= elapsedTime) { SOURCENEW_DEBUG("推进 MinIndex="<<GetMinIndex()<<" MaxIndex="<<GetMaxIndex()<<" 推进时间戳="<<elapsedTime); break; } } // piece过期,删除之 STREAMBUFFER_WARN("Storage::RemoveExpired: " << make_tuple(pieceIndex, baseIndicator.GetPieceIndex())); DoDelete(iter++); ++deletedCount; } while (m_dataPieces.size() > STORAGE_PIECE_LIMIT) { DoDelete(m_dataPieces.begin()); } //m_unfinishedDataPieces.RemoveOld(GetMinIndex()); return deletedCount; }
pair<bool, UINT> Storage::Delete(PieceInfoCollection::iterator iter) { if (iter == m_dataPieces.end()) { STREAMBUFFER_WARN("Storage::Delete cannot be found, so cann't del. "); return make_pair(false, 0); } return DoDelete(iter); }
void PyConsole::OnContextMenu(wxCommandEvent& event) { int id = event.GetId(); if( id == idCut ) DoCut(); else if( id == idCopy ) DoCopy(); else if( id == idPaste ) DoPaste(); else if( id == idDelete ) DoDelete(); else if( id == idSelectAll ) DoSelectAll(); }
/* * We have all of the parsed command line options in "pState". Now we just * have to do something useful with it. * * Returns 0 on success, 1 on error. */ int DoWork(NulibState* pState) { NuError err; switch (NState_GetCommand(pState)) { case kCommandAdd: err = DoAdd(pState); break; case kCommandExtract: err = DoExtract(pState); break; case kCommandExtractToPipe: err = DoExtractToPipe(pState); break; case kCommandTest: err = DoTest(pState); break; case kCommandListShort: err = DoListShort(pState); break; case kCommandListVerbose: err = DoListVerbose(pState); break; case kCommandListDebug: err = DoListDebug(pState); break; case kCommandDelete: err = DoDelete(pState); break; case kCommandHelp: err = DoHelp(pState); break; default: fprintf(stderr, "ERROR: unexpected command %d\n", NState_GetCommand(pState)); err = kNuErrInternal; Assert(0); break; } return (err != kNuErrNone); }
void QtButton::deleteBody() { Is_BodyFra = false; _BodyFraButton->setStyleSheet("background:transparent"); DoDelete(); }
bool wxMenuBase::Delete(wxMenuItem *item) { wxCHECK_MSG( item, false, wxT("invalid item in wxMenu::Delete") ); return DoDelete(item); }
/************************************************************************** * ISvItemCm_fnInvokeCommand() */ static HRESULT WINAPI ISvItemCm_fnInvokeCommand( IContextMenu2 *iface, LPCMINVOKECOMMANDINFO lpcmi) { ItemCmImpl *This = impl_from_IContextMenu2(iface); if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO)) FIXME("Is an EX structure\n"); TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); if( HIWORD(lpcmi->lpVerb)==0 && LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST) { TRACE("Invalid Verb %x\n",LOWORD(lpcmi->lpVerb)); return E_INVALIDARG; } if (HIWORD(lpcmi->lpVerb) == 0) { switch(LOWORD(lpcmi->lpVerb-This->verb_offset)) { case FCIDM_SHVIEW_EXPLORE: TRACE("Verb FCIDM_SHVIEW_EXPLORE\n"); DoOpenExplore(This, lpcmi->hwnd, "explore"); break; case FCIDM_SHVIEW_OPEN: TRACE("Verb FCIDM_SHVIEW_OPEN\n"); DoOpenExplore(This, lpcmi->hwnd, "open"); break; case FCIDM_SHVIEW_RENAME: TRACE("Verb FCIDM_SHVIEW_RENAME\n"); DoRename(This, lpcmi->hwnd); break; case FCIDM_SHVIEW_DELETE: TRACE("Verb FCIDM_SHVIEW_DELETE\n"); DoDelete(This); break; case FCIDM_SHVIEW_COPY: TRACE("Verb FCIDM_SHVIEW_COPY\n"); DoCopyOrCut(This, lpcmi->hwnd, FALSE); break; case FCIDM_SHVIEW_CUT: TRACE("Verb FCIDM_SHVIEW_CUT\n"); DoCopyOrCut(This, lpcmi->hwnd, TRUE); break; case FCIDM_SHVIEW_PROPERTIES: TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n"); DoOpenProperties(This, lpcmi->hwnd); break; default: FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)-This->verb_offset); return E_INVALIDARG; } } else { TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb)); if (strcmp(lpcmi->lpVerb,"delete")==0) DoDelete(This); else if (strcmp(lpcmi->lpVerb,"properties")==0) DoOpenProperties(This, lpcmi->hwnd); else { FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb)); return E_FAIL; } } return NOERROR; }
void nsCollect::ProcessData::DeleteFiles() { DoDelete(rngFile); DoDelete(optFile); DoDelete(xyFile); }
size_t Storage::RemoveExpired(const StreamIndicator& baseIndicator, UINT minBufferTime, UINT upperBound, UINT lowerBound) { LIVE_ASSERT(upperBound >= lowerBound); size_t deletedCount = 0; // 根据 base 计算出来了删除时间 UINT64 elapsedTime = baseIndicator.GetElapsedTime(); UINT64 elapsedTimeStamp = 0; LIVE_ASSERT(elapsedTime <= INT_MAX); if (elapsedTime > minBufferTime) { // 现在 elapsedTime 就是 理论推进时间戳 - 70s elapsedTime -= minBufferTime; // 根据 skipIndex 计算出来了删除时间 UINT skipIndex = upperBound; if( skipIndex == 0 ) { return 0; } PieceInfoCollection::iterator skipIter = m_dataPieces.find(skipIndex); LIVE_ASSERT( skipIter != m_dataPieces.end()); MediaDataPiecePtr skipPiece = skipIter->second.GetPiece(); CheckDataPiece(skipPiece); if( skipPiece->GetTimeStamp() - baseIndicator.GetTimeStamp() <= STORAGE_MIN_EXPIRE_REFER_TIME) { return 0; } // 现在 elapsedTimeForSkip 就是 SkipIndex时间戳 - 50s UINT64 elapsedTimeForSkip = skipPiece->GetTimeStamp() - baseIndicator.GetTimeStamp() - STORAGE_MIN_EXPIRE_REFER_TIME; // 此时 elapsedTime 就是 min(理论推进时间戳 - 70s, SkipIndex时间戳 - 50s) elapsedTime = min( elapsedTime, elapsedTimeForSkip); PieceInfoCollection::iterator iter = m_dataPieces.begin(); while (iter != m_dataPieces.end()) { MediaDataPiecePtr piece = iter->second.GetPiece(); CheckDataPiece(piece); UINT pieceIndex = iter->first; // 可能删掉upperBound对应的piece //LIVE_ASSERT(pieceIndex < upperBound); // 如果upperBound以后一直没有数据,或者距离很远才遇到下一片,则可能会发生upperBound对应的片也过时的情况 if (pieceIndex > upperBound) break; if (pieceIndex >= baseIndicator.GetPieceIndex()) { // peer端的BaseIndex不一定是最小的,需要加以检查 elapsedTimeStamp = piece->GetTimeStamp() - baseIndicator.GetTimeStamp(); if (elapsedTimeStamp >= elapsedTime) { break; } } // piece过期,删除之 STREAMBUFFER_WARN("Storage::RemoveExpired: " << make_tuple(baseIndicator.GetPieceIndex(), pieceIndex, piece->GetTimeStamp())); DoDelete(iter++); ++deletedCount; if (m_dataPieces.size() < 400) { // LIVE_ASSERT(false); } } } // 此处是设计之外的,是为了回避一个查不出来的BUG而添加 while (m_dataPieces.size() > STORAGE_PIECE_LIMIT) { DoDelete(m_dataPieces.begin()); ++deletedCount; } while (!m_dataPieces.empty()) { // 过滤掉跟upperBound相差太远的piece UINT tempPieceIndex = m_dataPieces.begin()->first; if (tempPieceIndex >= lowerBound) break; DoDelete(m_dataPieces.begin()); ++deletedCount; } #if defined(_WIN32_WCE) #pragma message("------wince下限制缓冲区的最大数据片数为600") while (m_dataPieces.size() > 600) { DoDelete(m_dataPieces.begin()); ++deletedCount; } #endif // m_unfinishedDataPieces.RemoveOld(GetMinIndex()); return deletedCount; }
static HRESULT WINAPI ItemMenu_InvokeCommand( IContextMenu3 *iface, LPCMINVOKECOMMANDINFO lpcmi) { ContextMenu *This = impl_from_IContextMenu3(iface); if (lpcmi->cbSize != sizeof(CMINVOKECOMMANDINFO)) FIXME("Is an EX structure\n"); TRACE("(%p)->(invcom=%p verb=%p wnd=%p)\n",This,lpcmi,lpcmi->lpVerb, lpcmi->hwnd); if (IS_INTRESOURCE(lpcmi->lpVerb) && LOWORD(lpcmi->lpVerb) > FCIDM_SHVIEWLAST) { TRACE("Invalid Verb %x\n", LOWORD(lpcmi->lpVerb)); return E_INVALIDARG; } if (IS_INTRESOURCE(lpcmi->lpVerb)) { switch(LOWORD(lpcmi->lpVerb)) { case FCIDM_SHVIEW_EXPLORE: TRACE("Verb FCIDM_SHVIEW_EXPLORE\n"); DoOpenExplore(This, lpcmi->hwnd, "explore"); break; case FCIDM_SHVIEW_OPEN: TRACE("Verb FCIDM_SHVIEW_OPEN\n"); DoOpenExplore(This, lpcmi->hwnd, "open"); break; case FCIDM_SHVIEW_RENAME: { IShellBrowser *browser; /* get the active IShellView */ browser = (IShellBrowser*)SendMessageA(lpcmi->hwnd, CWM_GETISHELLBROWSER, 0, 0); if (browser) { IShellView *view; if(SUCCEEDED(IShellBrowser_QueryActiveShellView(browser, &view))) { TRACE("(shellview=%p)\n", view); IShellView_SelectItem(view, This->apidl[0], SVSI_DESELECTOTHERS|SVSI_EDIT|SVSI_ENSUREVISIBLE|SVSI_FOCUSED|SVSI_SELECT); IShellView_Release(view); } } break; } case FCIDM_SHVIEW_DELETE: TRACE("Verb FCIDM_SHVIEW_DELETE\n"); DoDelete(This); break; case FCIDM_SHVIEW_COPY: TRACE("Verb FCIDM_SHVIEW_COPY\n"); DoCopyOrCut(This, lpcmi->hwnd, FALSE); break; case FCIDM_SHVIEW_CUT: TRACE("Verb FCIDM_SHVIEW_CUT\n"); DoCopyOrCut(This, lpcmi->hwnd, TRUE); break; case FCIDM_SHVIEW_PROPERTIES: TRACE("Verb FCIDM_SHVIEW_PROPERTIES\n"); DoOpenProperties(This, lpcmi->hwnd); break; default: FIXME("Unhandled Verb %xl\n",LOWORD(lpcmi->lpVerb)); return E_INVALIDARG; } } else { TRACE("Verb is %s\n",debugstr_a(lpcmi->lpVerb)); if (strcmp(lpcmi->lpVerb,"delete")==0) DoDelete(This); else if (strcmp(lpcmi->lpVerb,"properties")==0) DoOpenProperties(This, lpcmi->hwnd); else { FIXME("Unhandled string verb %s\n",debugstr_a(lpcmi->lpVerb)); return E_FAIL; } } return S_OK; }