8 namespace datastructure {
63 MLelement(
const E& val = E(),
const string& lab =
string())
191 virtual const string getDataStructureRepresentation()
const override final {
192 vector<const MLelement<E>*> nodes;
195 this->getListElements(
this, nodes);
202 unordered_map<const MLelement*, int> node_map { {
nullptr, -1} };
204 string nodes_JSON, links_JSON;
207 for (
const auto* e : nodes) {
208 if (node_map.emplace(e, i).second) {
211 nodes_JSON += e->getElementRepresentation() +
COMMA;
215 node_map.erase(
nullptr);
216 if (nodes_JSON.size()) {
217 nodes_JSON = nodes_JSON.erase(nodes_JSON.size() - 1);
221 for (
int k = 0; k < nodes.size(); k++) {
222 if (nodes[k]->
next !=
nullptr) {
224 to_string(node_map[nodes[k]]),
229 if (nodes[k]->sub_list !=
nullptr) {
231 nodes[k]->
links.at(nodes[k]->sub_list),
232 to_string(node_map[nodes[k]]),
233 to_string(node_map[nodes[k]->sub_list])) +
COMMA;
239 if (links_JSON.size()) {
240 links_JSON = links_JSON.erase(links_JSON.size() - 1);
243 string ml_list_json =
261 while (it !=
nullptr) {
265 getListElements(it->sub_list, nodes);
MLelement< E > * sub_list
Definition: MLelement.h:48
static const string getLinkRepresentation(const LinkVisualizer &lv, const string &src, const string &dest)
Definition: Element.h:256
MLelement< E > * getNext() const override
Definition: MLelement.h:143
MLelement< E > * getNext() override
Definition: MLelement.h:133
MLelement(const E &val=E(), const string &lab=string())
Definition: MLelement.h:63
const string COLON
Definition: DataStructure.h:51
void setNext(MLelement< E > *n)
Definition: MLelement.h:152
SLelement * next
Definition: SLelement.h:30
const string OPEN_BOX
Definition: DataStructure.h:54
virtual const string getDStype() const override
Definition: MLelement.h:182
MLelement * getSubList()
Definition: MLelement.h:123
void setColor(const Color &col)
Set the color to "col".
Definition: ElementVisualizer.h:79
MLelement(string label)
Definition: MLelement.h:78
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)
Definition: MLelement.h:92
bool getTag()
Gets the tag of the element.
Definition: MLelement.h:176
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)
Definition: MLelement.h:103
void setTag(bool t)
Sets the tag of the element.
Definition: MLelement.h:167
const string CLOSE_BOX
Definition: DataStructure.h:55
This class can be used to instantiate Multi-list Elements.
Definition: MLelement.h:45
ElementVisualizer * getVisualizer()
Definition: Element.h:136
unordered_map< Element *, LinkVisualizer > links
Definition: Element.h:87
void setShape(const Shape &shp)
Set the shape of the element.
Definition: ElementVisualizer.h:122
const string COMMA
Definition: DataStructure.h:50
bool tag
Definition: MLelement.h:49
const string QUOTE
Definition: DataStructure.h:49
Definition: ElementVisualizer.h:10