https://gitlab.inria.fr/line/aide-group/macrovsa
Tip revision: 31a87d848f8ab28a06ccf77d0b359fc966974138 authored by vthierry on 15 December 2025, 21:31:50 UTC
sync from makefile
sync from makefile
Tip revision: 31a87d8
List.cpp
#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;
}
}
