void Network::Reset(int n,int s,int t) { _V.resize(n); _E.clear(); for (_s = 0;_s < n;_s++) { _V[_s].e = _V[_s].l = _V[_s].o = -1; } _s = s,_t = t; }
void StoreBuffer::MonoTypeBuffer<T>::compactRemoveDuplicates(StoreBuffer *owner) { EdgeSet duplicates; if (!duplicates.init()) return; /* Failure to de-dup is acceptable. */ LifoAlloc::Enum insert(*storage_); for (LifoAlloc::Enum e(*storage_); !e.empty(); e.popFront<T>()) { T *edge = e.get<T>(); if (!duplicates.has(edge->location())) { insert.updateFront<T>(*edge); insert.popFront<T>(); /* Failure to insert will leave the set with duplicates. Oh well. */ duplicates.put(edge->location()); } } storage_->release(insert.mark()); duplicates.clear(); }
void StoreBuffer::RelocatableMonoTypeBuffer<T>::compactMoved(StoreBuffer *owner) { LifoAlloc &storage = *this->storage_; EdgeSet invalidated; if (!invalidated.init()) CrashAtUnhandlableOOM("RelocatableMonoTypeBuffer::compactMoved: Failed to init table."); /* Collect the set of entries which are currently invalid. */ for (LifoAlloc::Enum e(storage); !e.empty(); e.popFront<T>()) { T *edge = e.get<T>(); if (edge->isTagged()) { if (!invalidated.put(edge->location())) CrashAtUnhandlableOOM("RelocatableMonoTypeBuffer::compactMoved: Failed to put removal."); } else { invalidated.remove(edge->location()); } } /* Remove all entries which are in the invalidated set. */ LifoAlloc::Enum insert(storage); for (LifoAlloc::Enum e(storage); !e.empty(); e.popFront<T>()) { T *edge = e.get<T>(); if (!edge->isTagged() && !invalidated.has(edge->location())) { insert.updateFront<T>(*edge); insert.popFront<T>(); } } storage.release(insert.mark()); invalidated.clear(); #ifdef DEBUG for (LifoAlloc::Enum e(storage); !e.empty(); e.popFront<T>()) JS_ASSERT(!e.get<T>()->isTagged()); #endif }