8 namespace datastructure {
66 MLelement(
const E& val = E(),
const string& lab =
string())
199 virtual const string getDataStructureRepresentation()
const override final {
200 vector<const MLelement<E>*> nodes;
203 this->getListElements(
this, nodes);
210 unordered_map<const MLelement*, int> node_map { {
nullptr, -1} };
212 string nodes_JSON, links_JSON;
215 for (
const auto* e : nodes) {
216 if (node_map.emplace(e, i).second) {
219 nodes_JSON += e->getElementRepresentation() +
COMMA;
223 node_map.erase(
nullptr);
224 if (nodes_JSON.size()) {
225 nodes_JSON = nodes_JSON.erase(nodes_JSON.size() - 1);
229 for (
int k = 0; k < nodes.size(); k++) {
230 if (nodes[k]->
next !=
nullptr) {
232 to_string(node_map[nodes[k]]),
237 if (nodes[k]->sub_list !=
nullptr) {
239 nodes[k]->
links.at(nodes[k]->sub_list),
240 to_string(node_map[nodes[k]]),
241 to_string(node_map[nodes[k]->sub_list])) +
COMMA;
247 if (links_JSON.size()) {
248 links_JSON = links_JSON.erase(links_JSON.size() - 1);
251 string ml_list_json =
270 while (it !=
nullptr) {
274 getListElements(it->sub_list, nodes);
MLelement< E > * sub_list
Definition: MLelement.h:50
static const string getLinkRepresentation(const LinkVisualizer &lv, const string &src, const string &dest)
Definition: Element.h:273
MLelement< E > * getNext() const override
Retrieves the element following this element - const version.
Definition: MLelement.h:149
MLelement< E > * getNext() override
Retrieves the element following this element.
Definition: MLelement.h:139
MLelement(const E &val=E(), const string &lab=string())
constructor
Definition: MLelement.h:66
const string COLON
Definition: DataStructure.h:51
void setNext(MLelement< E > *n)
Sets the element to point to the next MLelement.
Definition: MLelement.h:158
SLelement * next
Definition: SLelement.h:30
const string OPEN_BOX
Definition: DataStructure.h:54
virtual const string getDStype() const override
Return the string representaion of element.
Definition: MLelement.h:190
MLelement * getSubList()
Gets the sublist at this node, if it exists.
Definition: MLelement.h:129
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:94
MLelement(string label)
Creates an MLelement object.
Definition: MLelement.h:83
const string CLOSE_CURLY
Definition: DataStructure.h:53
This class represents Color, and supports rgba, hexadecimal and named color values.
Definition: Color.h:51
The singly linked list element, derived from Element.
Definition: SLelement.h:27
MLelement(E e, MLelement< E > *next)
Creates an MLelement object.
Definition: MLelement.h:98
bool getTag()
Gets the tag of the element.
Definition: MLelement.h:182
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4
void setSubList(MLelement< E > *sl)
Sets the start of a new sublist to the MLelement "next".
Definition: MLelement.h:109
void setTag(bool t)
Sets the tag of the element.
Definition: MLelement.h:173
const string CLOSE_BOX
Definition: DataStructure.h:55
This class can be used to instantiate Multi-list Elements.
Definition: MLelement.h:47
ElementVisualizer * getVisualizer()
Get the element visualizer object.
Definition: Element.h:144
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:95
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:140
const string COMMA
Definition: DataStructure.h:50
bool tag
Definition: MLelement.h:51
const string QUOTE
Definition: DataStructure.h:49
Definition: ElementVisualizer.h:10