I forgor to push this, this code is like months old lol
This commit is contained in:
parent
ecce3951fb
commit
391dc19c74
1
.gitignore
vendored
1
.gitignore
vendored
@ -208,3 +208,4 @@
|
|||||||
/Semester 4/Assignments/MapASDV_CalebFontenot/nbproject/private/
|
/Semester 4/Assignments/MapASDV_CalebFontenot/nbproject/private/
|
||||||
/Semester 4/Assignments/MapASDV_CalebFontenot/build/
|
/Semester 4/Assignments/MapASDV_CalebFontenot/build/
|
||||||
/Semester 4/Assignments/Hashing_CalebFontenot/target/
|
/Semester 4/Assignments/Hashing_CalebFontenot/target/
|
||||||
|
/Semester 4/Assignments/MP2_CalebFontenot/target/
|
||||||
|
172
Semester 4/Assignments/MP2_CalebFontenot/Matricies.html
Normal file
172
Semester 4/Assignments/MP2_CalebFontenot/Matricies.html
Normal file
@ -0,0 +1,172 @@
|
|||||||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Matrices.java</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
|
<style type="text/css">
|
||||||
|
<!--
|
||||||
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||||
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
||||||
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
||||||
|
.number {color: #6897bb}
|
||||||
|
.string {color: #6a8759}
|
||||||
|
.ST4 {color: #9876aa}
|
||||||
|
.ST5 {color: #ffc66d}
|
||||||
|
.comment {color: #808080}
|
||||||
|
.whitespace {color: #505050}
|
||||||
|
.ST1 {color: #ffc66d; font-family: monospace; font-weight: bold; font-style: italic}
|
||||||
|
.ST3 {color: #9876aa; font-family: monospace; font-weight: bold; font-style: italic}
|
||||||
|
.ST0 {color: #287bde}
|
||||||
|
.literal {color: #cc7832}
|
||||||
|
.ST2 {font-family: monospace; font-weight: bold; font-style: italic}
|
||||||
|
-->
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 4/Assignments/MP2_CalebFontenot/src/main/java/com/calebfontenot/mp2_calebfontenot/Matrices.java</td></tr></table>
|
||||||
|
<pre>
|
||||||
|
<span class="comment">/*</span>
|
||||||
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt</span><span class="comment"> to change this license</span>
|
||||||
|
<span class="comment"> * Click </span><span class="ST0">nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java</span><span class="comment"> to edit this template</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
<span class="literal">package</span> com.calebfontenot.mp2_calebfontenot;
|
||||||
|
|
||||||
|
<span class="literal">import</span> java.math.BigInteger;
|
||||||
|
<span class="literal">import</span> java.util.ArrayList;
|
||||||
|
<span class="literal">import</span> java.util.concurrent.ForkJoinPool;
|
||||||
|
<span class="literal">import</span> java.util.concurrent.RecursiveTask;
|
||||||
|
|
||||||
|
<span class="comment">/**</span>
|
||||||
|
<span class="comment"> *</span>
|
||||||
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
||||||
|
<span class="comment">*/</span>
|
||||||
|
<span class="literal">public</span> <span class="literal">class</span> Matrices {
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">main</span>(String[] args) {
|
||||||
|
Matrices.<span class="ST2">multiplyParallel</span>();
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> ArrayList<ArrayList<BigInteger>> <span class="ST1">createRandomMatrix</span>(<span class="literal">int</span> rows, <span class="literal">int</span> columns) {
|
||||||
|
ArrayList<ArrayList<BigInteger>> matrix = <span class="literal">new</span> ArrayList<ArrayList<BigInteger>>(rows);
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < rows; ++i) {
|
||||||
|
ArrayList<BigInteger> row = <span class="literal">new</span> ArrayList<BigInteger>();
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < columns; ++j) {
|
||||||
|
row.add(<span class="literal">new</span> BigInteger(Integer.<span class="ST2">toString</span>(<span class="number">1</span> + (<span class="literal">int</span>) (Math.<span class="ST2">random</span>() * <span class="number">9</span>))));
|
||||||
|
}
|
||||||
|
matrix.add(row);
|
||||||
|
}
|
||||||
|
<span class="literal">return</span> matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">multiplyParallel</span>() {
|
||||||
|
<span class="comment">/*</span>
|
||||||
|
<span class="comment"> ArrayList<ArrayList<BigInteger>> A = new ArrayList<>();</span>
|
||||||
|
<span class="comment"> ArrayList<BigInteger> row1 = new ArrayList<>();</span>
|
||||||
|
<span class="comment"> row1.add(new BigInteger("6"));</span>
|
||||||
|
<span class="comment"> row1.add(new BigInteger("1"));</span>
|
||||||
|
<span class="comment"> ArrayList<BigInteger> row2 = new ArrayList<>();</span>
|
||||||
|
<span class="comment"> row2.add(new BigInteger("7"));</span>
|
||||||
|
<span class="comment"> row2.add(new BigInteger("2"));</span>
|
||||||
|
<span class="comment"> A.add(row1);</span>
|
||||||
|
<span class="comment"> A.add(row2);</span>
|
||||||
|
|
||||||
|
<span class="comment"> ArrayList<ArrayList<BigInteger>> B = new ArrayList<>();</span>
|
||||||
|
<span class="comment"> row1 = new ArrayList<BigInteger>();</span>
|
||||||
|
<span class="comment"> row1.add(new BigInteger("4"));</span>
|
||||||
|
<span class="comment"> row1.add(new BigInteger("1"));</span>
|
||||||
|
<span class="comment"> row1.add(new BigInteger("2"));</span>
|
||||||
|
<span class="comment"> row2 = new ArrayList<BigInteger>();</span>
|
||||||
|
<span class="comment"> row2.add(new BigInteger("1"));</span>
|
||||||
|
<span class="comment"> row2.add(new BigInteger("9"));</span>
|
||||||
|
<span class="comment"> row2.add(new BigInteger("5"));</span>
|
||||||
|
<span class="comment"> B.add(row1);</span>
|
||||||
|
<span class="comment"> B.add(row2);</span>
|
||||||
|
<span class="comment"> */</span>
|
||||||
|
ArrayList<ArrayList<BigInteger>> A = Matrices.<span class="ST2">createRandomMatrix</span>(<span class="number">2</span>, <span class="number">2</span>);
|
||||||
|
ArrayList<ArrayList<BigInteger>> B = Matrices.<span class="ST2">createRandomMatrix</span>(<span class="number">2</span>, <span class="number">3</span>);
|
||||||
|
|
||||||
|
RecursiveTask<ArrayList<ArrayList<BigInteger>>> rt
|
||||||
|
= <span class="literal">new</span> Matrices.MatricesMultiplication(<span class="number">0</span>, A.size() - <span class="number">1</span>, A, B);
|
||||||
|
ForkJoinPool pool = <span class="literal">new</span> ForkJoinPool();
|
||||||
|
ArrayList<ArrayList<BigInteger>> mul = pool.invoke(rt);
|
||||||
|
|
||||||
|
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="string">MATRIX A</span><span class="string">"</span>);
|
||||||
|
<span class="ST2">printMatrix</span>(A);
|
||||||
|
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">MATRIX B</span><span class="string">"</span>);
|
||||||
|
<span class="ST2">printMatrix</span>(B);
|
||||||
|
System.<span class="ST3">out</span>.println(<span class="string">"</span><span class="literal">\n</span><span class="string">MATRIX AxB</span><span class="string">"</span>);
|
||||||
|
<span class="ST2">printMatrix</span>(mul);
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">private</span> <span class="literal">static</span> <span class="literal">void</span> <span class="ST1">printMatrix</span>(ArrayList<ArrayList<BigInteger>> matrix) {
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < matrix.size(); ++i) {
|
||||||
|
System.<span class="ST3">out</span>.println(matrix.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">static</span> <span class="literal">class</span> <span class="ST2">MatricesMultiplication</span> <span class="literal">extends</span> RecursiveTask<ArrayList<ArrayList<BigInteger>>> {
|
||||||
|
|
||||||
|
ArrayList<ArrayList<BigInteger>> <span class="ST4">A</span>;
|
||||||
|
ArrayList<ArrayList<BigInteger>> <span class="ST4">B</span>;
|
||||||
|
ArrayList<ArrayList<BigInteger>> <span class="comment">AxB</span>;
|
||||||
|
<span class="literal">final</span> <span class="literal">int</span> <span class="ST4">HOW_MANY_ROWS_IN_PARALLEL</span> = <span class="number">3</span>;<span class="comment">// threshold</span>
|
||||||
|
<span class="literal">int</span> <span class="ST4">startIndex</span>;
|
||||||
|
<span class="literal">int</span> <span class="ST4">endIndex</span>;
|
||||||
|
|
||||||
|
<span class="literal">public</span> MatricesMultiplication(<span class="literal">int</span> startIndex, <span class="literal">int</span> endIndex, ArrayList<ArrayList<BigInteger>> A, ArrayList<ArrayList<BigInteger>> B) {
|
||||||
|
<span class="literal">this</span>.<span class="ST4">startIndex</span> = startIndex;
|
||||||
|
<span class="literal">this</span>.<span class="ST4">endIndex</span> = endIndex;
|
||||||
|
<span class="literal">this</span>.<span class="ST4">A</span> = A;
|
||||||
|
<span class="literal">this</span>.<span class="ST4">B</span> = B;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
<span class="literal">protected</span> ArrayList<ArrayList<BigInteger>> <span class="ST5">compute</span>() {
|
||||||
|
<span class="comment">// Base case: if the number of rows in A is less than or equal to the threshold,</span>
|
||||||
|
<span class="comment">// perform matrix multiplication sequentially</span>
|
||||||
|
<span class="literal">if</span> (<span class="ST4">endIndex</span> - <span class="ST4">startIndex</span> + <span class="number">1</span> <= <span class="ST4">HOW_MANY_ROWS_IN_PARALLEL</span>) {
|
||||||
|
ArrayList<ArrayList<BigInteger>> result = <span class="literal">new</span> ArrayList<>();
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="ST4">startIndex</span>; i <= <span class="ST4">endIndex</span>; i++) {
|
||||||
|
ArrayList<BigInteger> rowResult = <span class="literal">new</span> ArrayList<>();
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> j = <span class="number">0</span>; j < <span class="ST4">B</span>.get(<span class="number">0</span>).size(); j++) {
|
||||||
|
BigInteger sum = BigInteger.<span class="ST3">ZERO</span>;
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> k = <span class="number">0</span>; k < <span class="ST4">A</span>.get(<span class="number">0</span>).size(); k++) {
|
||||||
|
sum = sum.add(<span class="ST4">A</span>.get(i).get(k).multiply(<span class="ST4">B</span>.get(k).get(j)));
|
||||||
|
}
|
||||||
|
rowResult.add(sum);
|
||||||
|
}
|
||||||
|
result.add(rowResult);
|
||||||
|
}
|
||||||
|
<span class="literal">return</span> result;
|
||||||
|
} <span class="literal">else</span> {
|
||||||
|
<span class="comment">// Split the task into smaller subtasks</span>
|
||||||
|
<span class="literal">int</span> middle = (<span class="ST4">startIndex</span> + <span class="ST4">endIndex</span>) / <span class="number">2</span>;
|
||||||
|
<span class="ST2">MatricesMultiplication</span> leftTask = <span class="literal">new</span> MatricesMultiplication(<span class="ST4">startIndex</span>, middle, <span class="ST4">A</span>, <span class="ST4">B</span>);
|
||||||
|
<span class="ST2">MatricesMultiplication</span> rightTask = <span class="literal">new</span> MatricesMultiplication(middle + <span class="number">1</span>, <span class="ST4">endIndex</span>, <span class="ST4">A</span>, <span class="ST4">B</span>);
|
||||||
|
|
||||||
|
<span class="comment">// Fork the subtasks</span>
|
||||||
|
leftTask.fork();
|
||||||
|
ArrayList<ArrayList<BigInteger>> rightResult = rightTask.compute();
|
||||||
|
|
||||||
|
<span class="comment">// Join the results of the subtasks</span>
|
||||||
|
ArrayList<ArrayList<BigInteger>> leftResult = leftTask.join();
|
||||||
|
|
||||||
|
<span class="comment">// Merge the results</span>
|
||||||
|
ArrayList<ArrayList<BigInteger>> result = <span class="literal">new</span> ArrayList<>();
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < leftResult.size(); i++) {
|
||||||
|
result.add(<span class="literal">new</span> ArrayList<>(leftResult.get(i)));
|
||||||
|
}
|
||||||
|
<span class="literal">for</span> (<span class="literal">int</span> i = <span class="number">0</span>; i < rightResult.size(); i++) {
|
||||||
|
result.add(<span class="literal">new</span> ArrayList<>(rightResult.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="literal">return</span> result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</pre></body>
|
||||||
|
</html>
|
14
Semester 4/Assignments/MP2_CalebFontenot/pom.xml
Normal file
14
Semester 4/Assignments/MP2_CalebFontenot/pom.xml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.calebfontenot</groupId>
|
||||||
|
<artifactId>MP2_CalebFontenot</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
<exec.mainClass>com.calebfontenot.mp2_calebfontenot.MP2_CalebFontenot</exec.mainClass>
|
||||||
|
</properties>
|
||||||
|
</project>
|
@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.calebfontenot.mp2_calebfontenot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class MP2_CalebFontenot {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
System.out.println("Hello World!");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,142 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||||
|
*/
|
||||||
|
package com.calebfontenot.mp2_calebfontenot;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.ForkJoinPool;
|
||||||
|
import java.util.concurrent.RecursiveTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author caleb
|
||||||
|
*/
|
||||||
|
public class Matrices {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Matrices.multiplyParallel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<ArrayList<BigInteger>> createRandomMatrix(int rows, int columns) {
|
||||||
|
ArrayList<ArrayList<BigInteger>> matrix = new ArrayList<ArrayList<BigInteger>>(rows);
|
||||||
|
for (int i = 0; i < rows; ++i) {
|
||||||
|
ArrayList<BigInteger> row = new ArrayList<BigInteger>();
|
||||||
|
for (int j = 0; j < columns; ++j) {
|
||||||
|
row.add(new BigInteger(Integer.toString(1 + (int) (Math.random() * 9))));
|
||||||
|
}
|
||||||
|
matrix.add(row);
|
||||||
|
}
|
||||||
|
return matrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void multiplyParallel() {
|
||||||
|
/*
|
||||||
|
ArrayList<ArrayList<BigInteger>> A = new ArrayList<>();
|
||||||
|
ArrayList<BigInteger> row1 = new ArrayList<>();
|
||||||
|
row1.add(new BigInteger("6"));
|
||||||
|
row1.add(new BigInteger("1"));
|
||||||
|
ArrayList<BigInteger> row2 = new ArrayList<>();
|
||||||
|
row2.add(new BigInteger("7"));
|
||||||
|
row2.add(new BigInteger("2"));
|
||||||
|
A.add(row1);
|
||||||
|
A.add(row2);
|
||||||
|
|
||||||
|
ArrayList<ArrayList<BigInteger>> B = new ArrayList<>();
|
||||||
|
row1 = new ArrayList<BigInteger>();
|
||||||
|
row1.add(new BigInteger("4"));
|
||||||
|
row1.add(new BigInteger("1"));
|
||||||
|
row1.add(new BigInteger("2"));
|
||||||
|
row2 = new ArrayList<BigInteger>();
|
||||||
|
row2.add(new BigInteger("1"));
|
||||||
|
row2.add(new BigInteger("9"));
|
||||||
|
row2.add(new BigInteger("5"));
|
||||||
|
B.add(row1);
|
||||||
|
B.add(row2);
|
||||||
|
*/
|
||||||
|
ArrayList<ArrayList<BigInteger>> A = Matrices.createRandomMatrix(2, 2);
|
||||||
|
ArrayList<ArrayList<BigInteger>> B = Matrices.createRandomMatrix(2, 3);
|
||||||
|
|
||||||
|
RecursiveTask<ArrayList<ArrayList<BigInteger>>> rt
|
||||||
|
= new Matrices.MatricesMultiplication(0, A.size() - 1, A, B);
|
||||||
|
ForkJoinPool pool = new ForkJoinPool();
|
||||||
|
ArrayList<ArrayList<BigInteger>> mul = pool.invoke(rt);
|
||||||
|
|
||||||
|
System.out.println("MATRIX A");
|
||||||
|
printMatrix(A);
|
||||||
|
System.out.println("\nMATRIX B");
|
||||||
|
printMatrix(B);
|
||||||
|
System.out.println("\nMATRIX AxB");
|
||||||
|
printMatrix(mul);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void printMatrix(ArrayList<ArrayList<BigInteger>> matrix) {
|
||||||
|
for (int i = 0; i < matrix.size(); ++i) {
|
||||||
|
System.out.println(matrix.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class MatricesMultiplication extends RecursiveTask<ArrayList<ArrayList<BigInteger>>> {
|
||||||
|
|
||||||
|
ArrayList<ArrayList<BigInteger>> A;
|
||||||
|
ArrayList<ArrayList<BigInteger>> B;
|
||||||
|
ArrayList<ArrayList<BigInteger>> AxB;
|
||||||
|
final int HOW_MANY_ROWS_IN_PARALLEL = 3;// threshold
|
||||||
|
int startIndex;
|
||||||
|
int endIndex;
|
||||||
|
|
||||||
|
public MatricesMultiplication(int startIndex, int endIndex, ArrayList<ArrayList<BigInteger>> A, ArrayList<ArrayList<BigInteger>> B) {
|
||||||
|
this.startIndex = startIndex;
|
||||||
|
this.endIndex = endIndex;
|
||||||
|
this.A = A;
|
||||||
|
this.B = B;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ArrayList<ArrayList<BigInteger>> compute() {
|
||||||
|
// Base case: if the number of rows in A is less than or equal to the threshold,
|
||||||
|
// perform matrix multiplication sequentially
|
||||||
|
if (endIndex - startIndex + 1 <= HOW_MANY_ROWS_IN_PARALLEL) {
|
||||||
|
ArrayList<ArrayList<BigInteger>> result = new ArrayList<>();
|
||||||
|
for (int i = startIndex; i <= endIndex; i++) {
|
||||||
|
ArrayList<BigInteger> rowResult = new ArrayList<>();
|
||||||
|
for (int j = 0; j < B.get(0).size(); j++) {
|
||||||
|
BigInteger sum = BigInteger.ZERO;
|
||||||
|
for (int k = 0; k < A.get(0).size(); k++) {
|
||||||
|
sum = sum.add(A.get(i).get(k).multiply(B.get(k).get(j)));
|
||||||
|
}
|
||||||
|
rowResult.add(sum);
|
||||||
|
}
|
||||||
|
result.add(rowResult);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
// Split the task into smaller subtasks
|
||||||
|
int middle = (startIndex + endIndex) / 2;
|
||||||
|
MatricesMultiplication leftTask = new MatricesMultiplication(startIndex, middle, A, B);
|
||||||
|
MatricesMultiplication rightTask = new MatricesMultiplication(middle + 1, endIndex, A, B);
|
||||||
|
|
||||||
|
// Fork the subtasks
|
||||||
|
leftTask.fork();
|
||||||
|
ArrayList<ArrayList<BigInteger>> rightResult = rightTask.compute();
|
||||||
|
|
||||||
|
// Join the results of the subtasks
|
||||||
|
ArrayList<ArrayList<BigInteger>> leftResult = leftTask.join();
|
||||||
|
|
||||||
|
// Merge the results
|
||||||
|
ArrayList<ArrayList<BigInteger>> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < leftResult.size(); i++) {
|
||||||
|
result.add(new ArrayList<>(leftResult.get(i)));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < rightResult.size(); i++) {
|
||||||
|
result.add(new ArrayList<>(rightResult.get(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user