From 939d6874d114f5a39396f28aeb6ebc17a0dc652b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Tue, 23 Jul 2013 23:32:30 -0700 Subject: BFS searcher. --- lib/Core/Searcher.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'lib/Core/Searcher.cpp') diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp index d08cd1b1..778ef0ef 100644 --- a/lib/Core/Searcher.cpp +++ b/lib/Core/Searcher.cpp @@ -88,6 +88,40 @@ void DFSSearcher::update(ExecutionState *current, /// +ExecutionState &BFSSearcher::selectState() { + return *states.front(); +} + +void BFSSearcher::update(ExecutionState *current, + const std::set &addedStates, + const std::set &removedStates) { + states.insert(states.end(), + addedStates.begin(), + addedStates.end()); + for (std::set::const_iterator it = removedStates.begin(), + ie = removedStates.end(); it != ie; ++it) { + ExecutionState *es = *it; + if (es == states.front()) { + states.pop_front(); + } else { + bool ok = false; + + for (std::deque::iterator it = states.begin(), + ie = states.end(); it != ie; ++it) { + if (es==*it) { + states.erase(it); + ok = true; + break; + } + } + + assert(ok && "invalid state removed"); + } + } +} + +/// + ExecutionState &RandomSearcher::selectState() { return *states[theRNG.getInt32()%states.size()]; } -- cgit 1.4.1