Bridges-C++  3.4.2
Bridges(C++ API)
ElementArray.h
Go to the documentation of this file.
1 #ifndef ELE_ARRAY_H
2 #define ELE_ARRAY_H
3 
4 #include "Element.h"
5 namespace bridges {
6  namespace datastructure {
12  template <typename E, size_t X, size_t Y = 1, size_t Z = 1>
13  class ElementArray : public DataStructure {
14  private:
15  array<array<array<Element<E>*, Z>, Y>, X> data;
16  public:
18  for (const auto& x : data) { // each Array<Array> in data
19  for (const auto& y : x) { // each Array in Array<Array>
20  y.fill(nullptr); //initializes to nullptr
21  }
22  }
23  }
24  Element<E>* getValue(size_t x, size_t y = 0, size_t z = 0) {
25  return data[x][y][z];
26  }
27  const Element<E>* getValue(size_t x, size_t y = 0, size_t z = 0) const {
28  return data[x][y][z];
29  }
30  void setValue(Element<E>* el, size_t x, size_t y = 0, size_t z = 0) {
31  data[x][y][z] = el;
32  }
33 
34  virtual const string getDStype() const override {
35  return "Array";
36  }
37  private:
38  virtual const pair<string, string> getDataStructureRepresentation() const override final {
39  unordered_set<const Element<E>*> nodes;
40  for (const auto& x : data) { // each Array<Array> in data
41  for (const auto& y : x) { // each Array in Array<Array>
42  for (const auto& z : y) { // each Element* in Array
43  if (z) {
44  nodes.emplace(z);
45  }
46  }
47  }
48  }
49  return Element<E>::generateJSON(nodes); // generate the JSON
50  }
51  };
52  }
53 }
54 #endif
This is the superclass of all data structure types in BRIDGES.
Definition: DataStructure.h:73
Currently unused class, ignore.
Definition: ElementArray.h:13
const Element< E > * getValue(size_t x, size_t y=0, size_t z=0) const
Definition: ElementArray.h:27
virtual const string getDStype() const override
Definition: ElementArray.h:34
Element< E > * getValue(size_t x, size_t y=0, size_t z=0)
Definition: ElementArray.h:24
ElementArray()
Definition: ElementArray.h:17
void setValue(Element< E > *el, size_t x, size_t y=0, size_t z=0)
Definition: ElementArray.h:30
This is the fundamental building block for all data structures in BRIDGES.
Definition: Element.h:52
these methods convert byte arrays in to base64 codes and are used in BRIDGES to represent the color a...
Definition: alltypes.h:4