LR0: Converted ::getExpected from std::vector to std::set

This commit is contained in:
Paul Beckingham 2016-01-02 14:33:05 -05:00
parent 1305c0cb55
commit 31b53e8c23
2 changed files with 6 additions and 6 deletions

View file

@ -116,13 +116,12 @@ LR0::Closure LR0::getClosure (const Closure& items)
////////////////////////////////////////////////////////////////////////////////
// Collect a unique set of expected symbols from the closure.
std::vector <std::string> LR0::getExpected (const Closure& closure)
std::set <std::string> LR0::getExpected (const Closure& closure)
{
std::vector <std::string> expected;
std::set <std::string> expected;
for (auto& item : closure)
if (! item.done () &&
std::find (expected.begin (), expected.end (), item.next ()) == expected.end ())
expected.push_back (item.next ());
if (! item.done ())
expected.insert (item.next ());
return expected;
}

View file

@ -28,6 +28,7 @@
#define INCLUDED_LR0
#include <Grammar.h>
#include <set>
#include <map>
#include <string>
@ -68,7 +69,7 @@ public:
private:
Closure getClosure (const Closure&);
std::vector <std::string> getExpected (const Closure&);
std::set <std::string> getExpected (const Closure&);
private:
// Copy of the augmented grammar.