diff --git a/Hello_World_Tutorials/ARRAY1D.html b/Hello_World_Tutorials/ARRAY1D.html new file mode 100644 index 000000000..e181b9747 --- /dev/null +++ b/Hello_World_Tutorials/ARRAY1D.html @@ -0,0 +1,284 @@ + + + + + + + + + + + + + Bridges - Hello World Visualization Tutorial + + + +
+ +
+ +
+
+ Array<E> implements a array in BRIDGES, and it can be used to create arrays of type Element<E> + + +

1D Array - An Example BRIDGES program

+
+
Java
+
C++
+
+
+
+

Create a new .java file

+ +

Imports

+
    +
  • We need to include these Bridges files to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .java file, enter the following code snippets:
  • + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +
+ +

Main Exception

+
    +
  • By adding a throw exception we can forgo messy try/catch blocks in our code for our Bridges calls
  • +
  • In your .java file, add a throw exception to the main function so it looks like this:
  • + public static void main(String[] args) throws Exception +
+ +

Inside our Main

+
    +
  • First we need to create our BRIDGES object and initialize our BRIDGES Credentials
  • + Bridges<String, String> bridge = new Bridges<String,String>(1, "YOUR_API_KEY", "YOUR_USER_ID"); Note that you will need to replace the two fields in this call with your BRIDGES credentials. +

    +

  • Then we can create our Array
  • + +//declare array size +int arraySize = 10; + +//declare the array dimension +//(10,1,1) for 1D array, where 10 is the array size +int[] dims = {arraySize, 1, 1}; +Array<Integer> my_array = new Array<Integer> (1, dims); + +
  • Now populate the array with dummy data.
  • + +for (int k = 0; k < my_array.getSize(); k++){ + my_array.setValue(k, new Element<Integer>(String.valueOf(k), k*k)); + my_array.getValue(k).getVisualizer().setColor("red"); +} + + + +
  • Now change the color of the elements.
  • + +my_array.getValue(1).getVisualizer().setColor("green"); +my_array.getValue(3).getVisualizer().setColor("blue"); +my_array.getValue(5).getVisualizer().setColor("magenta"); +my_array.getValue(7).getVisualizer().setColor("cyan"); +my_array.getValue(9).getVisualizer().setColor("yellow"); + + + +
  • Now we pass the array object to BRIDGES
  • + bridge.setDataStructure(my_array); +
  • Finally we call the visualize function
  • + bridge.visualize(); +
+

Code Summary: Your .java file should look like this

+ + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +public class arr1d { +public static void main(String[] args) throws Exception{ + + //create the Bridges object + Bridges<String, Integer< bridges + = new Bridges<String, Integer<(10, "486749122386", "kalpathi60"); + + + + // for 1D array + int arraySize = 10; + int[] dims = {arraySize, 1, 1}; + Array<Integer> my_array = new Array<Integer> (1, dims); + + for (int k = 0; k < my_array.getSize(); k++){ + my_array.setValue(k, new Element<Integer>(String.valueOf(k), k*k)); + my_array.getValue(k).getVisualizer().setColor("red"); + } + + my_array.getValue(1).getVisualizer().setColor("green"); + my_array.getValue(3).getVisualizer().setColor("blue"); + my_array.getValue(5).getVisualizer().setColor("magenta"); + my_array.getValue(7).getVisualizer().setColor("cyan"); + my_array.getValue(9).getVisualizer().setColor("yellow"); + + //set visualizer type + bridges.setDataStructure(my_array); + + bridges.getVisualizer().setVisualizeJSON(true); + + // visualize the list + bridges.visualize(); + } +} + + +
+
+

Create a new .cpp file

+ +

Includes

+
    +
  • We need to include these Bridges headers to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .cpp file, enter the following code snippets:
  • + +#include "Bridges.h" +#include "Element.h" + +
+ +

Namespace

+
    +
  • By using this namespace we can forgo messy scope specifiers in our code for our Bridges calls
  • +
  • In your .cpp file, enter the following code snippet:
  • + using namespace bridges; +
+ +

Inside our Main

+
    +
  • First we need to initialize our Bridges Credentials
  • + Bridges::initialize(1, "YOUR_API_KEY","YOUR_USER_ID"); +

    + Note that you must replace the two strings above with your BRIDGES credentials. +

    +

  • Then we can create our Array.
  • + +Element<string> *el_array = new Element<string>[10]; + + +
  • Now populate the array with dummy data.
  • + +for (int k = 0; k < 10; k++) + el_array[k].setLabel("Element " + to_string(k)); + +
  • Now change the color of the elements.
  • + +el_array[0].getVisualizer()->setColor(Color("red")); +el_array[1].getVisualizer()->setColor(Color("green")); +el_array[3].getVisualizer()->setColor(Color("blue")); +el_array[5].getVisualizer()->setColor("magenta"); +el_array[7].getVisualizer()->setColor("cyan"); +el_array[9].getVisualizer()->setColor("yellow"); + +
  • Now we pass the first element of our singly linked list to Bridges
  • + Bridges::setDataStructure(el_array, 10); +
  • Finally we call the visualize function
  • + Bridges::visualize(); +
+

Code Summary: Your .cpp file should look like this

+ +#include <iostream> +#include <string> + +using namespace std; + +#define LOCAL_SERVER 0 + +#include "Bridges.h" +#include "Element.h" + +using namespace bridges; +int main() { + +#if LOCAL_SERVER + Bridges<string, string> *bridges = new Bridges<string, string>(0, + "856807706412", "kalpathi60"); +#else + Bridges::initialize(0, "kalpathi60", "486749122386"); +#endif + + Element<string> *el_array = new Element<string>[10]; + + el_array[0].setLabel("Element 0"); + + for (int k = 0; k < 10; k++) + el_array[k].setLabel("Element " + to_string(k)); + + el_array[0].getVisualizer()->setColor(Color("red")); + el_array[1].getVisualizer()->setColor(Color("green")); + el_array[3].getVisualizer()->setColor(Color("blue")); + el_array[5].getVisualizer()->setColor("magenta"); + el_array[7].getVisualizer()->setColor("cyan"); + el_array[9].getVisualizer()->setColor("yellow"); + + + Bridges::setTitle("Array Example"); + Bridges::setDataStructure(el_array, 10); + Bridges::visualize(); + + return 0; +} + + +
+
+ +

Bridges Visualization

+ +
+ +
+

Well done! You’ve just created your first Bridges project!

+
+ + + +
+ + + diff --git a/Hello_World_Tutorials/ARRAY2D.html b/Hello_World_Tutorials/ARRAY2D.html new file mode 100644 index 000000000..a823e7715 --- /dev/null +++ b/Hello_World_Tutorials/ARRAY2D.html @@ -0,0 +1,292 @@ + + + + + + + + + + + + + Bridges - Hello World Visualization Tutorial + + + +
+ +
+ +
+
+ Array<E> implements a array in BRIDGES, and it can be used to create arrays of type Element<E> + + +

2D Array - An Example BRIDGES program

+
+
Java
+
C++
+
+
+
+

Create a new .java file

+ +

Imports

+
    +
  • We need to include these Bridges files to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .java file, enter the following code snippets:
  • + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +
+ +

Main Exception

+
    +
  • By adding a throw exception we can forgo messy try/catch blocks in our code for our Bridges calls
  • +
  • In your .java file, add a throw exception to the main function so it looks like this:
  • + +public static void main(String[] args) throws Exception + +
+ +

Inside our Main

+
    +
  • First we need to create our BRIDGES object and initialize our BRIDGES Credentials
  • + +Bridges<String, String> bridge = new Bridges<String,String>(1, "YOUR_API_KEY", "YOUR_USER_ID"); + + + +

    Note that you will need to replace the two fields in this call with your BRIDGES credentials.

    + +
  • Then we can create our 2D Array
  • + +// for 2D array 5x5 +int columns = 5; +int rows = 5; +int[] dims = {columns, rows, 1}; +Array<Integer> my_array = new Array<Integer> (2, dims); + + + +
  • Now populate the 2d array with dummy data.
  • + +for (int rowAt = 0; rowAt < rows; k++){ + for (int columnAt = 0; columnAt < columns; k++){ + my_array.setValue(rowAt, columnAt, new Element<Integer>(String.valueOf(k), k*k)); + my_array.getValue(rowAt, columnAt).getVisualizer().setColor(circ_dllist.getRandomColor()); + } +} + + + + +
  • Now change the color of the elements.
  • + +my_array.getValue(0,0).getVisualizer().setColor("green"); +my_array.getValue(0,3).getVisualizer().setColor("blue"); +my_array.getValue(3,0).getVisualizer().setColor("magenta"); +my_array.getValue(3,3).getVisualizer().setColor("cyan"); +my_array.getValue(1,1).getVisualizer().setColor("yellow"); + + + + +
  • Now we pass the array object to BRIDGES
  • + bridge.setDataStructure(my_array); +
  • Finally we call the visualize function
  • + bridge.visualize(); +
+

Code Summary: Your .java file should look like this

+ + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +public class Array1DExample { +public static void main(String[] args) throws Exception{ + + //create the Bridges object + Bridges<String, Integer< bridges = new Bridges<String, Integer<(10, "YOUR_API_KEY", "YOUR_USER_ID"); + + + // for 2D array 5x5 + int columns = 5; + int rows = 5; + int[] dims = {columns, rows, 1}; + Array<Integer> my_array = new Array<Integer> (2, dims); + + for (int rowAt = 0; rowAt < rows; k++){ + for (int columnAt = 0; columnAt < columns; k++){ + my_array.setValue(rowAt, columnAt, new Element<Integer>(String.valueOf(k), k*k)); + my_array.getValue(rowAt, columnAt).getVisualizer().setColor(circ_dllist.getRandomColor()); + } + } + + my_array.getValue(0,0).getVisualizer().setColor("green"); + my_array.getValue(0,3).getVisualizer().setColor("blue"); + my_array.getValue(3,0).getVisualizer().setColor("magenta"); + my_array.getValue(3,3).getVisualizer().setColor("cyan"); + my_array.getValue(1,1).getVisualizer().setColor("yellow"); + + //set visualizer type + bridges.setDataStructure(my_array); + + // visualize the list + bridges.visualize(); + } +} + + +
+
+

Create a new .cpp file

+ +

Includes

+
    +
  • We need to include these Bridges headers to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .cpp file, enter the following code snippets:
  • + +#include "Bridges.h" +#include "Element.h" + +
+ +

Namespace

+
    +
  • By using this namespace we can forgo messy scope specifiers in our code for our Bridges calls
  • +
  • In your .cpp file, enter the following code snippet:
  • + using namespace bridges; +
+ +

Inside our Main

+
    +
  • First we need to initialize our Bridges Credentials
  • + Bridges::initialize(1, "YOUR_API_KEY","YOUR_USER_ID"); +

    + Note that you must replace the two strings above with your BRIDGES credentials. +

    +

  • Then we can create our 2D Array
  • + +int dims[3] = {4, 4, 1}; +Array<string> *arr = new Array<string>(2, dims); + + + +
  • Now populate the 2d array with dummy data.
  • + +for (int k = 0; k<10; k++) + el_array[k].setLabel("Element " + to_string(k)); + + + +
  • Now change the color of specific elements.
  • + +arr->getValue(0,0).getVisualizer()->setColor(Color("red")); +arr->getValue(0,3).getVisualizer()->setColor(Color("green")); +arr->getValue(3,0).getVisualizer()->setColor(Color("blue")); +arr->getValue(3,3).getVisualizer()->setColor(Color("magenta")); +arr->getValue(1,1).getVisualizer()->setColor(Color("cyan")); +arr->getValue(2,2).getVisualizer()->setColor(Color("yellow")); + +
  • Now we pass the array object to BRIDGES.
  • + Bridges::setDataStructure(&e0;); +
  • Finally we call the visualize function.
  • + Bridges::visualize(); +
+

Code Summary: Your .cpp file should look like this

+ +#include <iostream> +#include <string> + +using namespace std; + +#include "Bridges.h" +#include "Element.h" + +using namespace bridges; +int main() { + +Bridges::initialize(0, "YOUR_API_KEY", "YOUR_USER_ID"); + +Element<string> *arr = new Element<string>[10]; + +for (int i = 0; i < dims[1]; k++) +for (int j = 0; j < dims[0]; j++) + arr-<arr(i,j).setLabel("Element " + to_string(i*dims[0]+j)); + +arr->getValue(0,0).getVisualizer()->setColor(Color("red")); +arr->getValue(0,3).getVisualizer()->setColor(Color("green")); +arr->getValue(3,0).getVisualizer()->setColor(Color("blue")); +arr->getValue(3,3).getVisualizer()->setColor(Color("magenta")); +arr->getValue(1,1).getVisualizer()->setColor(Color("cyan")); +arr->getValue(2,2).getVisualizer()->setColor(Color("yellow")); + + +Bridges::setTitle("Array 2D Example"); +Bridges::setDataStructure(arr); +Bridges::visualize(); + +return 0; +} + + +
+
+ + + +

Bridges Visualization

+ +
+ +
+

Well done! You’ve just created your first Bridges project!

+
+ + + +
+ + + diff --git a/Hello_World_Tutorials/ARRAY3D.html b/Hello_World_Tutorials/ARRAY3D.html new file mode 100644 index 000000000..01415f602 --- /dev/null +++ b/Hello_World_Tutorials/ARRAY3D.html @@ -0,0 +1,308 @@ + + + + + + + + + + + + + Bridges - Hello World Visualization Tutorial + + + +
+ +
+ +
+
+ Array<E> implements a array in BRIDGES, and it can be used to create arrays of type Element<E> + + + +

3D Array - An Example BRIDGES program

+
+
Java
+
C++
+
+
+ +
+

Create a new .java file

+ +

Imports

+
    +
  • We need to include these Bridges files to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .java file, enter the following code snippets:
  • + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +
+ +

Main Exception

+
    +
  • By adding a throw exception we can forgo messy try/catch blocks in our code for our Bridges calls
  • +
  • In your .java file, add a throw exception to the main function so it looks like this:
  • + +public static void main(String[] args) throws Exception + +
+ +

Inside our Main

+
    +
  • First we need to create our BRIDGES object and initialize our BRIDGES Credentials
  • + +Bridges<String, String> bridge = new Bridges<String,String>(1, "YOUR_API_KEY", "YOUR_USER_ID"); + + Note that you will need to replace the two fields in this call with your BRIDGES credentials. +

    +

  • Then we can create our 3D Array
  • + +// for 3D array 4x4x4 +int[] dims = {4, 4, 4}; +Array<Integer> my_array = new Array<Integer> (3, dims); + + + +
  • Now populate the 3d array with dummy data.
  • + +int n = 0; +for (int k = 0; k < dims[0]; k++){ +for (int j = 0; j < dims[1]; j++) +for (int i = 0; i < dims[2]; i++) + my_array.setValue(i, j, k, new Element(String.valueOf(k), + n++)); +} + + + +
  • Now change the color of all the elements.
  • + +for (int i = 0; i < dims[0]; i++) + my_array.getValue(i, i, i).getVisualizer().setColor("red"); + + +
  • Now change the color of specific elements.
  • + +my_array.getValue(0, 3, 0).getVisualizer().setColor(0, 255, 255, 1.0f); +my_array.getValue(0, 3, 1).getVisualizer().setColor("green"); +my_array.getValue(0, 3, 2).getVisualizer().setColor("blue"); +my_array.getValue(0, 3, 3).getVisualizer().setColor("magenta"); + + + +
  • Now we pass the array object to BRIDGES
  • + bridge.setDataStructure(my_array); +
  • Finally we call the visualize function
  • + bridge.visualize(); +
+

Code Summary: Your .java file should look like this

+ + +import bridges.connect.Bridges; +import bridges.base.Array; +import bridges.base.Element; + +public class arr1d { +public static void main(String[] args) throws Exception{ + + //create the Bridges object + Bridges<String, Integer< bridges = new Bridges<String, Integer<(10, "486749122386", "kalpathi60"); + + // for 3D array 4x4x4 + int[] dims = {4, 4, 4}; + Array<Integer> my_array = new Array<Integer> (3, dims); + + int n = 0; + for (int k = 0; k < dims[0]; k++){ + for (int j = 0; j < dims[1]; j++) + for (int i = 0; i < dims[2]; i++) + my_array.setValue(i, j, k, new Element(String.valueOf(k),n++)); + } + + my_array.getValue(0, 3, 0).getVisualizer().setColor(0, 255, 255, 1.0f); + my_array.getValue(0, 3, 1).getVisualizer().setColor("green"); + my_array.getValue(0, 3, 2).getVisualizer().setColor("blue"); + my_array.getValue(0, 3, 3).getVisualizer().setColor("magenta"); + + //set visualizer type + bridges.setDataStructure(my_array); + + // visualize the list + bridges.visualize(); + } +} + + +
+ +
+

Create a new .cpp file

+ +

Includes

+
    +
  • We need to include these Bridges headers to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .cpp file, enter the following code snippets:
  • + +#include "Bridges.h" +#include "Element.h" + + +
+ +

Namespace

+
    +
  • By using this namespace we can forgo messy scope specifiers in our code for our Bridges calls
  • +
  • In your .cpp file, enter the following code snippet:
  • + +using namespace bridges; + + +
+ +

Inside our Main

+
    +
  • First we need to initialize our Bridges Credentials
  • + +Bridges::initialize(1, "YOUR_API_KEY","YOUR_USER_ID"); + + +

    + Note that you must replace the two strings above with your BRIDGES credentials. +

    + +

  • Then we can create our 3D Array
  • + +int dims[3] = {4, 4, 4}; +Array *arr = new Array(3, dims); + + + +
  • Now populate the 3d array with dummy data.
  • + +for (int k = 0; k<10; k++) + el_array[k].setLabel("Element " + to_string(k)); + + + + +
  • Now change the color of specific elements.
  • + +arr->getValue(0,0,0).getVisualizer()->setColor(Color("red")); +arr->getValue(0,3,0).getVisualizer()->setColor(Color("green")); +arr->getValue(3,0,0).getVisualizer()->setColor(Color("blue")); +arr->getValue(3,3,0).getVisualizer()->setColor(Color("magenta")); +arr->getValue(1,1,0).getVisualizer()->setColor(Color("cyan")); +arr->getValue(2,2,0).getVisualizer()->setColor(Color("yellow")); + + +
  • Now we pass the first element of our singly linked list to Bridges
  • +Bridges::setDataStructure(&e0;); +
  • Finally we call the visualize function
  • +Bridges::visualize(); + +
+

Code Summary: Your .cpp file should look like this

+ +#include <iostream> +#include <string> + +using namespace std; + + +#include "Bridges.h" +#include "Element.h" + +using namespace bridges; +int main() { + + Bridges::initialize(0, "YOUR_API_KEY", "YOUR_USER_ID"); + + int dims[3] = {4, 4, 4}; + Array<string> *arr = new Array<string> (3, dims); + + for (int k = 0; k < dims[0]; i++) + for (int j = 0; j < dims[1]; j++) + for (int i = 0; i < dims[2]; i++) + arr->getValue(i, j, k).setLabel("El " + to_string(i*dims[0]+j)); + + for (int k = 0; k < 10; k++) + el_array[k].setLabel("Element " + to_string(k)); + + arr->getValue(0,0,0).getVisualizer()->setColor(Color("red")); + arr->getValue(0,3,0).getVisualizer()->setColor(Color("green")); + arr->getValue(3,0,0).getVisualizer()->setColor(Color("blue")); + arr->getValue(3,3,0).getVisualizer()->setColor(Color("magenta")); + arr->getValue(1,1,0).getVisualizer()->setColor(Color("cyan")); + arr->getValue(2,2,0).getVisualizer()->setColor(Color("yellow")); + + + Bridges::setTitle("Array 3D Example"); + Bridges::setDataStructure(el_array, 10); + Bridges::visualize(); + + return 0; +} + + +
+
+ + + +

Bridges Visualization

+ +
+ +
+

Well done! You’ve just created your first Bridges project!

+
+ + + +
+ + + diff --git a/Hello_World_Tutorials/CDLL.html b/Hello_World_Tutorials/CDLL.html new file mode 100644 index 000000000..576114eb1 --- /dev/null +++ b/Hello_World_Tutorials/CDLL.html @@ -0,0 +1,249 @@ + + + + + + + + + + + + + Bridges - Hello World Visualization Tutorial + + + +
+ +
+ +
+
+ CircDLelement<E> implements a circular doubly linked list in BRIDGES and is + inherited from DElement<E> +



+

How does the CircDLelement<E> work?

+

+ CircDLelement<E> stands for Circular Doubly Linked Element, and is a container + that has two links, pointing to two other doubly linked elements. So + a CircDLelement<E> “knows” who + it’s pointing at, AND it knows who pointed at it. +



+ In this example, calling getNext() on CircDLelement2 will return CircDLelement3. + Calling getPrev() on CircDLelement2 will return CircDLelement1. CircDLelement3 points to CircDLelement1, and CircDLelement1 points to CircDLelement3. +

+ Notice that, since CircDLelement<E> has a getPrev() method, they can move + forwards AND backwards through the linked elements. +

+ +


+ + +

CircDLelement - BRIDGES Example

+
+
Java
+
C++
+
+
+
+

Create a new .java file

+ +

Imports

+
    +
  • We need to include these Bridges files to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .java file, enter the following code snippets:
  • + + import bridges.connect.Bridges; + import bridges.base.CircDLelement; + +
+ +

Main Exception

+
    +
  • By adding a throw exception we can forgo messy try/catch blocks in our code for our Bridges calls
  • +
  • In your .java file, add a throw exception to the main function so it looks like this:
  • + public static void main(String[] args) throws Exception +
+ +

Inside our Main

+
    +
  • First we need to create our Bridges object and initialize our Bridges Credentials
  • + Bridges<String, String> bridge = new Bridges<String,String>(2, "YOUR_API_KEY", "YOUR_USER_ID"); +

    + Note that you must replace the above strings with your BRIDGES credentials. +

    +

  • Then we can create our CircDLelement
  • + + CircDLelement<String> e0 = new CircDLelement<>("Hello", ""); + CircDLelement<String> e1 = new CircDLelement<>("World", ""); + CircDLelement<String> e2 = new CircDLelement<>("!", ""); + +
  • Now insert the CircDLelement into the list.
  • + + CircDLelement tail = el0; + tail = insertFront(tail, el1); + tail = insertFront(tail, el2); + +
  • Now we pass the first element of our datastruture to Bridges
  • + bridge.setDataStructure(e0); +
  • Finally we call the visualize function
  • + bridge.visualize(); +
+

Code Summary: Your .java file should look like this

+ + import bridges.connect.Bridges; + import bridges.base.CircDLelement; + + public class HelloWorld + { + public static void main(String[] args) throws Exception + { + //create the Bridges object + Bridges<String, String> bridge = new Bridges<String,String>(2, "YOUR_API_KEY", "YOUR_USER_ID"); + + //create elements + CircDLelement<String> e0 = new CircDLelement<>("Hello", ""); + CircDLelement<String> e1 = new CircDLelement<>("World", ""); + CircDLelement<String> e2 = new CircDLelement<>("!", ""); + + // insert elements into list + CircDLelement<String> tail = el0; + tail = insertFront(tail, el1); + tail = insertFront(tail, el2); + + //pass first element of data structure + bridge.setDataStructure(e0); + + //visualize data structure + bridge.visualize(); + } + } + + +
+ + +
+ + + +

Bridges Visualization

+ +
+ +
+

Well done! You’ve just created your first Bridges project!

+
+ + + +
+ + + diff --git a/Hello_World_Tutorials/CSLL.html b/Hello_World_Tutorials/CSLL.html new file mode 100644 index 000000000..3280c29c8 --- /dev/null +++ b/Hello_World_Tutorials/CSLL.html @@ -0,0 +1,250 @@ + + + + + + + + + + + + + Bridges - Hello World Visualization Tutorial + + + +
+ +
+ +
+
+ CircSLelement<E> implements a doubly linked list in BRIDGES and is +inherited from SElement<E> +



+

How does the CircSLelement<E> work?

+

+CircSLelement<E> stands for Circular Singly Linked Element and is a type +of container that has one link, pointing to another SLelement<E>. +So an CircSLelement<E> "knows" who it is pointing at but it does not know +who is pointing at it(if any). +



+In the above example, CircSLelement1 points to CircSLelement2. Calling getNext() +on CircSLelement1 will return a link to CircSLelement2, and calling getNext() on +CircSLelement2 will return a link to SLelement3. CircSLelement3 points to CircSLelement1. Calling getNext() on CircSLelement3 will return a link to CircSLelement1. +

+Also notice that there is no getPrev(). CircSLelement2 has no idea what +element came before it. So, you CANNOT go backwards. +

+ +
+ +

CircSLelement - An Example BRIDGES program

+
+
Java
+
C++
+
+
+
+

Create a new .java file

+ +

Imports

+
    +
  • We need to include these Bridges files to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .java file, enter the following code snippets:
  • + + import bridges.connect.Bridges; + import bridges.base.SLelement; + +
+ +

Main Exception

+
    +
  • By adding a throw exception we can forgo messy try/catch blocks in our code for our Bridges calls
  • +
  • In your .java file, add a throw exception to the main function so it looks like this:
  • + public static void main(String[] args) throws Exception +
+ +

Inside our Main

+
    +
  • First we need to create our BRIDGES object and initialize our BRIDGES Credentials
  • + Bridges<String, String> bridge = new Bridges<String,String>(1, "YOUR_API_KEY", "YOUR_USER_ID"); + Note that you will need to replace the two fields in this call with your BRIDGES credentials.

    +

  • Then we can create our SLelements
  • + + SLelement<String> e0 = new SLelement<>("Hello", ""); + SLelement<String> e1 = new SLelement<>("World", ""); + SLelement<String> e2 = new SLelement<>("!", ""); + +
  • Now link the SLelements together
  • + + e0.setNext(e1); + e1.setNext(e2); + +
  • Now we pass the first element(head) of our data structure to BRIDGES
  • + bridge.setDataStructure(e0); +
  • Finally we call the visualize function
  • + bridge.visualize(); +
+

Code Summary: Your .java file should look like this

+ + import bridges.connect.Bridges; + import bridges.base.SLelement; + + public class HelloWorld + { + public static void main(String[] args) throws Exception + { + //create the Bridges object + Bridges<String,String> bridge = new Bridges<String,String>(1, "YOUR_API_KEY", "YOUR_USER_ID"); + + //create a circular linkedlist + CircSLelement<String> el0 = new CircSLelement<String>("Example", "0"); + CircSLelement<String> el1 = new CircSLelement<String>("Of", "1"); + CircSLelement<String> el2 = new CircSLelement<String>("A", "2"); + CircSLelement<String> el3 = new CircSLelement<String>("Circular", "4"); + CircSLelement<String> el4 = new CircSLelement<String>("List", "4"); + + + CircSLelement<String> tail = el0; + tail = insertFront(tail, el1); + tail = insertFront(tail, el2); + tail = insertFront(tail, el3); + tail = insertFront(tail, el4); + + + el0.getLinkVisualizer(el1).setColor("red"); + el0.getLinkVisualizer(el1).setThickness(3); + el1.getLinkVisualizer(el2).setColor("green"); + el1.getLinkVisualizer(el2).setThickness(3); + el2.getLinkVisualizer(el3).setColor("blue"); + el2.getLinkVisualizer(el3).setThickness(3); + el3.getLinkVisualizer(el4).setColor("cyan"); + el3.getLinkVisualizer(el4).setThickness(3); + el4.getLinkVisualizer(el0).setColor("magenta"); + el4.getLinkVisualizer(el0).setThickness(3); + + el0.getVisualizer().setColor("red"); + + //pass first element of data structure + bridge.setDataStructure(el0); + + //visualize data structure + bridge.visualize(); + } + } + + +
+
+

Create a new .cpp file

+ +

Includes

+
    +
  • We need to include these Bridges headers to give access to all the classes/methods needed to interact with Bridges
  • +
  • In your .cpp file, enter the following code snippets:
  • + + #include "Bridges.h" + #include "CircSLelement.h" + +
+ +

Namespace

+
    +
  • By using this namespace we can forgo messy scope specifiers in our code for our Bridges calls
  • +
  • In your .cpp file, enter the following code snippet:
  • + using namespace bridges; +
+ +

Inside our Main

+
    +
  • First we need to initialize our Bridges Credentials
  • + Bridges::initialize(1, "YOUR_API_KEY","YOUR_USER_ID"); +

    + Note that you must replace the two strings above with your BRIDGES credentials. +

    +

  • Then we can create our CircSLelements
  • + + CircSLelement<int> *el0 = new CircSLelement<int>(0, "0"); + CircSLelement<int> *el1 = new CircSLelement<int>(1, "1"); + CircSLelement<int> *el2 = new CircSLelement<int>(2, "2"); + CircSLelement<int> *el3 = new CircSLelement<int>(3, "3"); + +
  • Now link the CircSLelements together
  • + + // link nodes + el0-<setNext(el1); + el1-<setNext(el2); + el2-<setNext(el3); + el3-<setNext(el0); + +
  • Now we pass the first element of our circular singly linked list to Bridges
  • + Bridges::setDataStructure(e11); +
  • Finally we call the visualize function
  • + Bridges::visualize(); +
+

Code Summary: Your .cpp file should look like this

+ + #include "Bridges.h" + #include "CircSLelement.h" + + using namespace bridges; + + int main() + { + //create the Bridges object + Bridges::initialize("YOUR_API_KEY","YOUR_USER_ID",1); + + //create elements + CircSLelement<int> *el0 = new CircSLelement<int>(0, "0"); + CircSLelement<int> *el1 = new CircSLelement<int>(1, "1"); + CircSLelement<int> *el2 = new CircSLelement<int>(2, "2"); + CircSLelement<int> *el3 = new CircSLelement<int>(3, "3"); + + // link nodes + el0-<setNext(el1); + el1-<setNext(el2); + el2-<setNext(el3); + el3-<setNext(el0); + + //pass first element of data structure + Bridges::setDataStructure(e11); + + //visualize data structure + Bridges::visualize(); + } + + +
+
+ + +

Bridges Visualization

+ +
+ +
+

Well done! You’ve just created your first Bridges project!

+
+ + + +
+ + + diff --git a/Hello_World_Tutorials/Tutorial_Header.html b/Hello_World_Tutorials/Tutorial_Header.html index 4e4ee2cbc..15141dade 100644 --- a/Hello_World_Tutorials/Tutorial_Header.html +++ b/Hello_World_Tutorials/Tutorial_Header.html @@ -7,11 +7,22 @@

Bridges User Guide and Tutorials

diff --git a/Hello_World_Tutorials/images/svg/cdl.svg b/Hello_World_Tutorials/images/svg/cdl.svg new file mode 100644 index 000000000..62b75f8e4 --- /dev/null +++ b/Hello_World_Tutorials/images/svg/cdl.svg @@ -0,0 +1,2 @@ + +
CircDLelement
3
[Not supported by viewer]
CircDLelement
1
[Not supported by viewer]
CircDLelement
2
[Not supported by viewer]
\ No newline at end of file diff --git a/Hello_World_Tutorials/images/svg/csl.svg b/Hello_World_Tutorials/images/svg/csl.svg new file mode 100644 index 000000000..c94ce9ff0 --- /dev/null +++ b/Hello_World_Tutorials/images/svg/csl.svg @@ -0,0 +1,2 @@ + +
CircSLelement
3
[Not supported by viewer]
CircSLelement
2
[Not supported by viewer]
CircSLelement
1
[Not supported by viewer]
\ No newline at end of file diff --git a/Hello_World_Tutorials/images/svg/dl.svg b/Hello_World_Tutorials/images/svg/dl.svg new file mode 100644 index 000000000..984207ce3 --- /dev/null +++ b/Hello_World_Tutorials/images/svg/dl.svg @@ -0,0 +1,2 @@ + +
DLelement
3
[Not supported by viewer]
DLelement
1
[Not supported by viewer]
DLelement
2
[Not supported by viewer]
NULL
[Not supported by viewer]
NULL
[Not supported by viewer]
\ No newline at end of file diff --git a/Hello_World_Tutorials/images/svg/sl.svg b/Hello_World_Tutorials/images/svg/sl.svg new file mode 100644 index 000000000..612fb4cef --- /dev/null +++ b/Hello_World_Tutorials/images/svg/sl.svg @@ -0,0 +1,2 @@ + +
SLelement
3
[Not supported by viewer]
SLelement
2
[Not supported by viewer]
SLelement
1
[Not supported by viewer]
NULL
[Not supported by viewer]
\ No newline at end of file diff --git a/Hello_World_Tutorials/tutorial.css b/Hello_World_Tutorials/tutorial.css index b2453b8e3..078935d31 100644 --- a/Hello_World_Tutorials/tutorial.css +++ b/Hello_World_Tutorials/tutorial.css @@ -14,7 +14,7 @@ body > *:not(script) font-family: 'open sans', sans-serif; display:inline-block; text-align: initial; - max-width:70em; + max-width:70em; } h1 { @@ -61,7 +61,7 @@ header nav span { cursor:default; } -header nav a +header nav a { display:inline-block; color: white; @@ -80,7 +80,7 @@ header nav *.dropdown-contents display: none; position:absolute; } -header nav *.dropdown-contents * +header nav *.dropdown-contents * { color: black; display: block; @@ -95,7 +95,9 @@ header nav *.dropdown-contents *:hover {background-color: #45a9ec} header nav > *:hover .dropdown-contents{display: block;} - +main{ + /*width: 90vw;*/ +} main ul { margin-left: .5em; @@ -188,4 +190,4 @@ footer * font-size: 11px; text-align: center; margin-bottom: 20px; -} \ No newline at end of file +}