void PriorityQueue::remove(PriorityItem* item) { if(item == 0x0) return; item->priority = 2<<31-1; downheap(top()); _remove(this,item); }
bool CFileAccess::remove(const char *file, bool recursive /* = false */) { Win32Wide wfile(file); DWORD att = GetFileAttributesW(wfile); if(att==0xFFFFFFFF) return false; SetFileAttributesW(wfile,att&~FILE_ATTRIBUTE_READONLY); if(att&FILE_ATTRIBUTE_DIRECTORY) { if(!recursive) { if(!RemoveDirectoryW(wfile)) return false; } else { cvs::wstring wpath = wfile; if(!_remove(wpath)) return false; } } else { if(!DeleteFileW(wfile)) return false; } return true; }
void* bset::remove(void* x) { if ( v_setroot == 0 ) return 0; else return _remove(x, v_setroot); }
void Selection::_clear() { _invalidateCachedLists(); while (!_objs.empty()) { SPObject *obj=_objs.front(); _remove(obj); } }
void list_remove_node ( list *list, listNode *search ) { listNode *prev = NULL; listNode *node = list->head; while ( node ) { if ( search == node ) { if ( node == list->head ) { list->head = node->next; } else if ( node == list->tail ) { list->tail = prev; } else { prev->next = node->next; } _remove ( list, node ); break; } prev = node; node = node->next; } }
int dfs(int x, int y) { if (y == 9) { if (!safe(x-1, y-1) || !safe(x-1, y-2)) return 0; x++, y = 0; } if (x == 9) { for (int i = 0; i < 9; i++) if (!safe(8, i)) return 0; for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) printf("%d%c", ret[i][j], j == 8 ? '\n' : ' '); return 1; } if (!safe(x-1, y-2)) return 0; if (dfs(x, y+1)) return 1; int f = canplace(x, y); if (f) { _remove(x, y); if (dfs(x, y+1)) return 1; _resume(x, y); } return 0; }
void xtimer_remove(xtimer_t *timer) { int state = irq_disable(); if (_is_set(timer)) { _remove(timer); } irq_restore(state); }
void ScreenLock::acceptStream(const QString uri) { if (!_isPending(uri)) return; emit streamAccepted(uri); _remove(uri); }
void ScreenLock::rejectStream(const QString uri) { if (!_isPending(uri)) return; emit streamRejected(uri); _remove(uri); }
///检测超时的元素,key的expire时间超过uiCurTime的全部失效 void UnistorStoreMemCache::checkExpire(CWX_UINT32 uiCurTime, CWX_UINT32 uiBatchNum){ CWX_UINT32 uiSlot=m_uiCurCheckSlotIndex; CWX_UINT32 uiPos=m_uiCurCheckSlotPos; CWX_UINT32 uiTotalSlot = m_cacheBufArrIndex + 1; CWX_UINT32 uiCheckNum = 0; UnistorStoreMemCacheItem* key=NULL; m_uiExpireNum = 0; for (; uiSlot<uiTotalSlot; uiSlot++){ while(UNISTOR_STORE_MEM_CACHE_SLOT_SIZE >= uiPos + sizeof(UnistorStoreMemCacheItem)){ key = (UnistorStoreMemCacheItem*)(m_cacheBufArr[uiSlot] + uiPos); if (UnistorStoreMemCacheItem::UNISTOR_MEM_ITEM_STATE_UNMALLOC == key->m_ucState){ break;///<剩余的空间没有分配 }else if (UnistorStoreMemCacheItem::UNISTOR_MEM_ITEM_STATE_USED == key->m_ucState){ if (key->m_uiExpire && (key->m_uiExpire < uiCurTime)){///<疑似超时 m_arrExpiredItem[m_uiExpireNum++] = key; } } uiCheckNum++; uiPos += key->size(); ///如果已经检查了指定的数量,则break。 if (uiCheckNum >= m_uiMaxPerCheckExpireNum) break; } ///如果已经检查了指定的数量,则break。 if (uiCheckNum >= m_uiMaxPerCheckExpireNum) break; uiPos = 0;///<从头开始 } ///如果已经满了,则break if (uiCheckNum < m_uiMaxPerCheckExpireNum){ ///本轮检测全部完成 CWX_ASSERT(uiSlot == uiTotalSlot); m_uiCurCheckSlotIndex = 0; m_uiCurCheckSlotPos = 0; }else{ m_uiCurCheckSlotIndex = uiSlot; m_uiCurCheckSlotPos = uiPos; } CWX_UINT32 uiIndex = 0; UnistorStoreMemCacheIter iter; while(uiIndex < m_uiExpireNum){ if (uiIndex + uiBatchNum > m_uiExpireNum){ uiBatchNum = m_uiExpireNum - uiIndex; } { ///获取写锁 CwxWriteLockGuard<CwxRwLock> lock(&m_rwLock); for (CWX_UINT32 i=0; i<uiBatchNum; i++){ iter.m_uiHash = UnistorStoreMemCacheItem::m_fnHash(m_arrExpiredItem[uiIndex]->getKey(), m_arrExpiredItem[uiIndex]->getKeyLen())%m_bucket_num; if (_findKey(m_arrExpiredItem[uiIndex], iter) && m_arrExpiredItem[uiIndex]->m_uiExpire && (m_arrExpiredItem[uiIndex]->m_uiExpire < uiCurTime)){ _remove(iter); } uiIndex++; } } } m_uiExpireNum = 0; }
int SymbolTable::remove(const char *name) { int offset = _lookup(name); if (offset == -1) return -1; _remove(offset, 1); return 0; }
void Selection::_removeObjectAncestors(SPObject *obj) { SPObject *parent = obj->parent; while (parent) { if (includes(parent)) { _remove(parent); } parent = parent->parent; } }
void Selection::remove(SPObject *obj) { g_return_if_fail(obj != NULL); g_return_if_fail(SP_IS_OBJECT(obj)); g_return_if_fail(includes(obj)); _invalidateCachedLists(); _remove(obj); _emitChanged(); }
bool bst<type>::remove(const type& x) { np cur = _search(_root, x); if (cur == NULL) { return false; } _remove(cur); _setheight(_root); return true; }
Task * toptask(PriorityList * plist) { if (plist && plist->priorities && !emptyq(plist->priorities->tasks)) { Task * task = pop(plist->priorities->tasks); _remove(plist, task); return task; } return NULL; }
void physics_remove(Entity ent) { PhysicsInfo *info; info = entitypool_get(pool, ent); if (!info) return; _remove(info); entitypool_remove(pool, ent); }
int SymbolTable::remove(Symbol *sym) { int offset; offset = _lookup(sym->name()); if (offset == -1 || syms[offset] != sym) return -1; _remove(offset, 0); return 0; }
void removeFlagged() { for(Particles::iterator iter = removeList.begin(); iter != removeList.end(); ++iter) { Particle *p = *iter; _remove(p); } removeList.clear(); }
void list_destroy ( list *list ) { listNode *node; while ( list->head != NULL ) { node = list->head; list->head = node->next; _remove ( list, node ); } }
/* Don't unlink() the socket, because it breaks systemd socket functionality. */ int remove(const char *pathname) { static int (*_remove)(const char*) = NULL; if (get_sd_fd(pathname) > 0) return 0; if (_remove == NULL) _remove = dlsym(RTLD_NEXT, "remove"); return _remove(pathname); }
static void TestBasic(void) { const char one[4] = {0x6F, 0x6E, 0x65, 0}; /* "one" */ const char one2[4] = {0x6F, 0x6E, 0x65, 0}; /* Get around compiler optimizations */ const char two[4] = {0x74, 0x77, 0x6F, 0}; /* "two" */ const char three[6] = {0x74, 0x68, 0x72, 0x65, 0x65, 0}; /* "three" */ const char omega[6] = {0x6F, 0x6D, 0x65, 0x67, 0x61, 0}; /* "omega" */ UErrorCode status = U_ZERO_ERROR; UHashtable *hash; hash = uhash_open(hashChars, isEqualChars, &status); if (U_FAILURE(status)) { log_err("FAIL: uhash_open failed with %s and returned 0x%08x\n", u_errorName(status), hash); return; } if (hash == NULL) { log_err("FAIL: uhash_open returned NULL\n"); return; } log_verbose("Ok: uhash_open returned 0x%08X\n", hash); _put(hash, one, 1, 0); _put(hash, omega, 24, 0); _put(hash, two, 2, 0); _put(hash, three, 3, 0); _put(hash, one, -1, 1); _put(hash, two, -2, 2); _put(hash, omega, 48, 24); _put(hash, one, 100, -1); _get(hash, three, 3); _remove(hash, two, -2); _get(hash, two, 0); _get(hash, one, 100); _put(hash, two, 200, 0); _get(hash, omega, 48); _get(hash, two, 200); if(_compareChars((void*)one, (void*)three) == TRUE || _compareChars((void*)one, (void*)one2) != TRUE || _compareChars((void*)one, (void*)one) != TRUE || _compareChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareChars failed\n"); } if(_compareIChars((void*)one, (void*)three) == TRUE || _compareIChars((void*)one, (void*)one) != TRUE || _compareIChars((void*)one, (void*)one2) != TRUE || _compareIChars((void*)one, NULL) == TRUE ) { log_err("FAIL: compareIChars failed\n"); } uhash_close(hash); }
void list_head ( list *list, void *element, u16 removeFromList ) { listNode *node = list->head; memcpy ( element, node->data, list->elementSize ); if ( removeFromList ) { list->head = node->next; _remove ( list, node ); } }
bool Window::removeWidget(Widget* widget) { if(!widget) return false; if(_remove(widget)) { _removeFromGeode(widget); resize(); return true; } return false; }
void UnistorStoreMemCache::remove( char const* szKey, CWX_UINT16 unKeyLen, CWX_UINT32 uiExpire){ char key_buf[UnistorStoreMemCacheItem::calKeySize(unKeyLen , 0)]; UnistorStoreMemCacheItem* key = (UnistorStoreMemCacheItem*)key_buf; memcpy(key->m_szBuf, szKey, unKeyLen); key->m_unKeyLen = unKeyLen; UnistorStoreMemCacheIter iter; iter.m_uiHash = UnistorStoreMemCacheItem::m_fnHash(key->getKey(), key->getKeyLen())%m_bucket_num; { CwxWriteLockGuard<CwxRwLock> lock(&m_rwLock); if (_findKey(key, iter) && (!uiExpire || (iter.m_pFind->m_uiExpire == uiExpire))){ _remove(iter); } } }
void BPlusTree::remove(const AttrType &k) { int blkPos = _findLeaf(k); std::cout << "BPlusTree::remove == k " << k.datai << std::endl; std::cout << "BPlusTree::remove == blkPos " << blkPos/BLOCK_SIZE << std::endl; Block blk; bufferManager->getBlock(filename, blkPos, blk); Node node(blk); _remove(blk, k); std::cout << "DONE! BPlusTree::remove == k " << k.datai << std::endl; // system("pause"); }
void UnistorReadCacheEx2::remove( char const* szKey, CWX_UINT16 unKeyLen){ char key_buf[UnistorReadCacheItemEx2::calKeySize(unKeyLen , 0)]; UnistorReadCacheItemEx2* key = (UnistorReadCacheItemEx2*)key_buf; memcpy(key->m_szBuf, szKey, unKeyLen); key->m_unKeyLen = unKeyLen; UnistorReadCacheExIter iter; iter.m_uiHash = UnistorReadCacheItemEx2::m_fnHash(key->getKey(), key->getKeyLen())%m_bucket_num; { CwxWriteLockGuard<CwxRwLock> lock(this->m_rwLock); if (_findKey(key, iter)){ _remove(iter); } } }
int _xtimer_set_absolute(xtimer_t *timer, uint32_t target) { uint32_t now = xtimer_now(); int res = 0; DEBUG("timer_set_absolute(): now=%" PRIu32 " target=%" PRIu32 "\n", now, target); timer->next = NULL; if ((target >= now) && ((target - XTIMER_BACKOFF) < now)) { /* backoff */ xtimer_spin_until(target + XTIMER_BACKOFF); _shoot(timer); return 0; } unsigned state = irq_disable(); if (_is_set(timer)) { _remove(timer); } timer->target = target; timer->long_target = _long_cnt; if (target < now) { timer->long_target++; } if ( (timer->long_target > _long_cnt) || !_this_high_period(target) ) { DEBUG("xtimer_set_absolute(): the timer doesn't fit into the low-level timer's mask.\n"); _add_timer_to_long_list(&long_list_head, timer); } else { if (_xtimer_lltimer_mask(now) >= target) { DEBUG("xtimer_set_absolute(): the timer will expire in the next timer period\n"); _add_timer_to_list(&overflow_list_head, timer); } else { DEBUG("timer_set_absolute(): timer will expire in this timer period.\n"); _add_timer_to_list(&timer_list_head, timer); if (timer_list_head == timer) { DEBUG("timer_set_absolute(): timer is new list head. updating lltimer.\n"); _lltimer_set(target - XTIMER_OVERHEAD); } } } irq_restore(state); return res; }
void ISpatial_DB::remove (ISpatial* S) { cs.Enter (); #ifdef DEBUG stat_remove.Begin (); #endif ISpatial_NODE* N = S->spatial.node_ptr; N->_remove (S); // Recurse if (N->_empty()) _remove(N->parent,N); #ifdef DEBUG stat_remove.End (); #endif cs.Leave (); }
/** * qentry_t->put(): Store object into linked-list structure. * * @param entry qentry_t pointer * @param name key name. * @param object object pointer * @param size size of the object * @param replace in case of false, just insert. in case of true, remove all * same key then insert object if found. * * @return true if successful, otherwise returns false. */ static bool _put(qentry_t *entry, const char *name, const void *data, size_t size, bool replace) { // check arguments if (entry == NULL || name == NULL || data == NULL || size <= 0) { return false; } // duplicate name char *dup_name = strdup(name); if (dup_name == NULL) return false; // duplicate object void *dup_data = malloc(size); if (dup_data == NULL) { free(dup_name); return false; } memcpy(dup_data, data, size); // make new object entry qentobj_t *obj = (qentobj_t *)malloc(sizeof(qentobj_t)); if (obj == NULL) { free(dup_name); free(dup_data); return false; } obj->name = dup_name; obj->data = dup_data; obj->size = size; obj->next = NULL; // if replace flag is set, remove same key if (replace == true) _remove(entry, dup_name); // make chain link if (entry->first == NULL) entry->first = entry->last = obj; else { entry->last->next = obj; entry->last = obj; } entry->num++; return true; }
void Selection::_removeObjectDescendants(SPObject *obj) { std::vector<SPObject*> toremove; for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end(); ++iter) { SPObject *sel_obj= dynamic_cast<SPObject*>(*iter); SPObject *parent = sel_obj->parent; while (parent) { if ( parent == obj ) { toremove.push_back(sel_obj); break; } parent = parent->parent; } } for ( std::vector<SPObject*>::const_iterator iter=toremove.begin();iter!=toremove.end(); ++iter) { _remove(*iter); } }