#include "List.hpp" #include "Binding.hpp" #include "algo.hpp" namespace macrovsa { void List::add(const Symbol& current, const Symbol& value) { const Symbol& next = getNext(current); AssociativeMap::erase(current); AssociativeMap::add(current, value); AssociativeMap::add(value, next); } void List::erase(const Symbol& current) { const Symbol& previous = getPrevious(current), & next = getNext(current); AssociativeMap::erase(previous); AssociativeMap::erase(current); AssociativeMap::add(previous, next); } const Symbol& List::getNext(const Symbol& current) const { return get(current); } const Symbol& List::getPrevious(const Symbol& current) const { for(auto it = get().cbegin(); it != get().cend(); it++) { const Symbol *c = it->second.second.cbegin()->second; if(c->equals(current)) { return *it->second.first; } } return nill; } }