I want to find out whether a number passed through a method is part of a randomly generated object (created from a tree map). I've been looking online to find an attribute to the class that can help me find it but have come up short, I've tried HashCodes, Equals(), and this the like... At the moment I have it set up like this and what I'm asking, I guess, is whether I'm using what I read right or wrong?
Here's the code:
public class a {
private final TreeMap<Integer,TreeMap<Integer,Double>> rectangle;
private final int height;
private final int width;
public a(int h, int w) {
this.rectangle = new TreeMap<>();
this.height = h;
this.width = w;
}
public double get(int i, int j) {
if ( i > j ) {
largest = i; // defined earlier
}
for(int a = 0; a < largest; a++) {
if (this.height.equals(a) == i && this.width.equals(a) == j){
int[] position = new int[1];
position[0] = i;
position[1] = j;``
}
else {
return 0.0;
}
}
}
Related
I have a project in which i have to implement a weighted quick-union with path compression algorithm.After seeing a number of others source code,i ended up in this:
public class UnionFind {
private int[] parent;
private int[] size;
private int maxItemCount; // maximum number of items from {0,1,...,N-1}
private int numItems; // number of items created
UnionFind(int N) {
this.N = N;
this.K = 0;
parent = new int[N];
size = new int[N];
for (int i = 0; i < N; i++) {
parent[i] = -1;
size[i] = 0;
}
}
void makeSet(int v) {
if (parent[v] != -1) return; // item v already belongs in a set
parent[v] = v;
size[v] = 1;
K++;
}
int find(int v) {
if (v == parent[v]) {
return v;
}
return parent[v] = find(parent[v]);
}
void unite(int v, int u) {
int x=find(v);
int y=find(u);
if(x!=y) {
parent[x]=y;
}
}
int setCount() {
int item=0;
for(int i=0;i<parent.length;i++) {
if(i==parent[i]) {
item++;
}
}
return item; // change appropriately
}
int itemCount() {
return K;
}
The task which has been assigned to me is to complete properly the following methods :
int find(int v)
void unite(int v,int u)
setCount(int v)
Well,the algorithm seems to be slow and i can't find a suitable solution.
Here are some issues:
The size information is not used, yet that information is crucial in keeping the desired performance. Most importantly, in unite:
size should be kept updated: the united set will have as many members as the two given sets had
size should determine which of the two root nodes should be the root of the united set, as this will keep the trees balanced
setCount has O(n) time complexity. It could give the information in O(1) time if you would keep track of that number in a member variable. I'd call it numSets. If setCount() is called a lot, this change will have a positive effect.
Not a problem, but naming variables as N and K is not helping to make the code readable. Why not give names that actually tell what they are, so you don't need to accompany their definitions with a comment to give that explanation?
Here is your code with those adaptations:
public class UnionFind {
private int[] parent;
private int[] size;
private int maxItemCount;
private int numItems;
private int numSets;
UnionFind(int maxItemCount) {
this.maxItemCount = maxItemCount;
numItems = 0;
numSets = 0;
parent = new int[maxItemCount];
size = new int[maxItemCount];
for (int i = 0; i < maxItemCount; i++) {
parent[i] = -1;
size[i] = 0;
}
}
void makeSet(int v) {
if (parent[v] != -1) return; // item v already belongs in a set
parent[v] = v;
size[v] = 1;
numItems++;
numSets++; // Keep track of number of sets
}
int find(int v) {
if (v == parent[v]) {
return v;
}
return parent[v] = find(parent[v]);
}
void unite(int v, int u) {
int x = find(v);
int y = find(u);
if (x != y) {
numSets--; // A union decreases the set count
// Determine which node becomes the root
if (size[x] < size[y]) {
parent[x] = y;
size[y] += size[x]; // Adapt size
} else {
parent[y] = x;
size[x] += size[y]; // Adapt size
}
}
}
int setCount() {
return numSets; // Kept track of it
}
int itemCount() {
return numItems;
}
}
i'm new in Java and working on a small project and having an issue, I hope you can help :
I'm trying to create a 2 dimensional array, inwhich each element is an Object of type Field that holds x and y ( as the coordinate of the element )
I'm throwing an error when the sent parameters for length and width are < 0
I'm testing my code in the main method but the error is always thrown meaning that the method to create the "map" is not receiving the correct parameters.
Note : the main method is in a different class ( main class )
```
import bbb.MyException;
public class CoordinateSystem {
private int length;
private int width;
private Field[][] map = createMap(getWidth(), getLength());
public CoordinateSystem(int width, int length) throws MyException {
this.width = width;
this.length = length;
}
public int getLength() {
return this.length;
}
public int getWidth() {
return this.width;
}
public class Field{
private int x;
private int y;
public void setX(int x) {
this.x = x;
}
public int getX() {
return x;
}
public void setY(int y) {
this.y = y;
}
public int getY() {
return y;
}
}
public Field[][] getMap() {
return map;
}
// Initializing a coordinate to each "field"
public Field[][] createMap(int width, int length) throws MyException {
if(width > 0 && length > 0){
Field[][] map = new Field[width][length];
for( int i = 0 ; i < width ; i++ ){
for( int j = 0 ; j < length ; j++ ){
map[i][j].setX(j);
map[i][j].setY(i);
}
}
return map;
} else{
throw new MyException("Sorry, can't create a field of width or height = 0 ");
}
}
}
public static void main(String[] args) throws MyException {
CoordinateSystem board = new CoordinateSystem(8, 9);
for( int i = 0 ; i < 8 ; i++ ){
for( int j = 0 ; j < 9 ; j++ ){
System.out.print(board.getMap()[i][j].getX());
System.out.println(board.getMap()[i][j].getY());
}
}
Exception in thread "main" bbb.MyException: Error! Sorry, can't create a
field of width or height = 0
at CoordinateSystem.createMap(CoordinateSystem.java:62)
at CoordinateSystem.<init>(CoordinateSystem.java:9)
at Main.main(Main.java:21)
Process finished with exit code 1
This line of your code (in method createMap())...
Field[][] map = new Field[width][length];
creates a two dimensional array but every element in the array is null.
Hence this line of your code (also in method createMap())
map[i][j].setX(j);
will throw a NullPointerException.
You need to explicitly create Field objects.
Also the Y coordinate of some of the Field elements in the map is zero as well as the X coordinate in some of the elements because (also in method createMap()) you start the for loops with zero. In order to fix that I add one to i and j when I call setX() and setY().
Here is the corrected code for the for loops in method createMap()
for( int i = 0 ; i < width ; i++ ){
for( int j = 0 ; j < length ; j++ ){
map[i][j] = new Field();
map[i][j].setX(j + 1);
map[i][j].setY(i + 1);
}
}
The only thing left to do is call method createMap(). Since map is a member of class CoordinateSystem, it seems logical to call createMap() from the constructor of CoordinateSystem.
public CoordinateSystem(int width, int length) throws MyException {
this.width = width;
this.length = length;
map = createMap(width, length);
}
Finally, for the sake of completeness, here is the entire [corrected] code of class CoordinateSystem
public class CoordinateSystem {
private int length;
private int width;
private Field[][] map;
public CoordinateSystem(int width, int length) throws MyException {
this.width = width;
this.length = length;
map = createMap(width, length);
}
public int getLength() {
return this.length;
}
public int getWidth() {
return this.width;
}
public class Field {
private int x;
private int y;
public void setX(int x) {
this.x = x;
}
public int getX() {
return x;
}
public void setY(int y) {
this.y = y;
}
public int getY() {
return y;
}
}
public Field[][] getMap() {
return map;
}
// Initializing a coordinate to each "field"
public Field[][] createMap(int width, int length) throws MyException {
if(width > 0 && length > 0){
Field[][] map = new Field[width][length];
for( int i = 0 ; i < width ; i++ ){
for( int j = 0 ; j < length ; j++ ){
map[i][j] = new Field();
map[i][j].setX(j + 1);
map[i][j].setY(i + 1);
}
}
return map;
}
else{
throw new Exception("Sorry, can't create a field of width or height = 0 ");
}
}
public static void main(String[] args) throws MyException {
CoordinateSystem board = new CoordinateSystem(8, 9);
for( int i = 0 ; i < 8 ; i++ ) {
for( int j = 0 ; j < 9 ; j++ ) {
System.out.print(board.getMap()[i][j].getX());
System.out.println(board.getMap()[i][j].getY());
}
}
}
}
You're initializing map before initializing width and height, so getWidth() and getHeight() both return 0. You can move the initialization inside the constructor and use the width and height there:
public class CoordinateSystem {
private int length;
private int width;
private Field[][] map;
public CoordinateSystem(int width, int length) throws MyException {
this.width = width;
this.length = length;
map = createMap(width, height);
}
// rest of the class...
I was attempting to implement Fruchterman and Reingold algorithm in Java, but for some reasons, the coordinate of output vertices sometimes occupy the same coordinates, which is not something this algorithm would want. Where did I go wrong?
Coordinate object (vector)
public class Coordinates {
private float x;
private float y;
public Coordinates(float xx, float yy){
x = xx; y = yy;
}
public float getX() {
return x;
}
public void setX(float x) {
this.x = x;
}
public float getY() {
return y;
}
public void setY(float y) {
this.y = y;
}
public String toString(){
return x+" "+y;
}
public Coordinates subtract(Coordinates c){
return new Coordinates(x-c.x, y - c.y);
}
public Coordinates add(Coordinates c){
return new Coordinates(x + c.x, y + c.y);
}
public Coordinates unit(){
if(length() == 0)
return new Coordinates(0.000001f,0.0000001f);
else
return new Coordinates(x/(float)Math.sqrt(x*x + y*y),y/(float)Math.sqrt(y*y + x*x));
}
public float length(){
return (float)Math.sqrt(x*x + y*y);
}
public float distance(Coordinates c){
return (float) Math.sqrt((x-c.x)*(x-c.x) + (y-c.y)*(y-c.y));
}
public Coordinates scale(float k){
return new Coordinates(k*x,k*y);
}
}
Node object
import java.util.LinkedList;
public class Node {
private LinkedList<Node> incidentList; //has 30 elements for 30 vertices. 1 if incident, 0 if not
private int color;
private Coordinates coord;
private Coordinates disp;
public Coordinates getDisp() {
return disp;
}
public void setDisp(float x, float y) {
disp.setX(x);
disp.setY(y);
}
public void setDisp(Coordinates d) {
disp = d;
}
private int id;
public Node(){
incidentList = new LinkedList<Node>();
color = 0;
coord = new Coordinates(0,0);
disp = new Coordinates(0,0);
id = -1;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public LinkedList<Node> getIncidentList() {
return incidentList;
}
public void addEdge(Node n) {
incidentList.add(n);
}
public void removeEdge(Node n){
incidentList.remove(n);
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public Coordinates getCoord() {
return coord;
}
public void setCoord(float x, float y) {
coord.setX(x);
coord.setY(y);
}
public int getDegree(){
return incidentList.size();
}
public boolean isAdjacent(Node n){
return incidentList.contains(n);
}
}
Graph object (with layout algorithm function frlayout)
import java.util.ArrayList;
import java.util.Random;
public class MyGraph{
private final int DISRESPECT = -1;
private final int MORECOLOR = -3;
private final float EPSILON = 0.003f;
private ArrayList<Node> graphNodes; //maximum of 30 vertices
private int nVertices = 0;
private int score = 50;
int maxColor = 0;
int[] colorPopulation = new int[15];
double boundx, boundy, C;
public double getBoundx() {
return boundx;
}
public void setBoundx(double boundx) {
this.boundx = boundx;
}
public double getBoundy() {
return boundy;
}
public void setBoundy(double boundy) {
this.boundy = boundy;
}
public double getC() {
return C;
}
public void setC(double c) {
C = c;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public int getnVertices() {
return nVertices;
}
public MyGraph(){
graphNodes = new ArrayList<Node>();
}
public ArrayList<Node> getGraphNodes() {
return graphNodes;
}
//add a new node into the graph
//also set the id of that node
public void addNode(Node n){
graphNodes.add(n);
n.setId(nVertices++);
}
public void addEdge(Node n1, Node n2){
n1.addEdge(n2);
n2.addEdge(n1);
}
//randomly generate a graph with parsity
public void randomGenerating(double parse){ //parse is between 0 and 1
Random gen = new Random(System.currentTimeMillis());
int tempNVertices = 6; //CHANGE HERE TO BECOME A RANDOM NUMBER
for(int i = 0; i< tempNVertices; i++){
Node n = new Node();
float x = 0,y = 0;
while(true){
boolean flag = true;
x = gen.nextFloat();
y = gen.nextFloat();
for(int j = 0; j < i; j++){
if(x*boundx == graphNodes.get(j).getCoord().getX() && y*boundx == graphNodes.get(j).getCoord().getY())
flag = false; break;
}
if (flag)
break;
}
n.setCoord((float)(x*boundx),(float)(y*boundy));
addNode(n);
}
for(int i = 0; i < tempNVertices; i++){
for(int j = i + 1; j < tempNVertices; j++){
if(gen.nextDouble() < parse){
addEdge(graphNodes.get(i),graphNodes.get(j));
}
}
}
}
public void frLayout(){
double w = boundx, h = boundy;
double area = w*h;
double k = C*Math.sqrt(area/nVertices);
double temperature = 1000;
for(int i = 0; i < nVertices; i++)
System.out.println(graphNodes.get(i).getCoord().getX()+" "+graphNodes.get(i).getCoord().getY());
System.out.println("------------------------------");
for(int m = 0; m< 900; m++){
for(int i = 0; i < nVertices; i++){
Node v = graphNodes.get(i);
v.setDisp(0,0);
for(int j = 0; j< nVertices; j++){
Node u = graphNodes.get(j);
if(i!= j){
Coordinates delta = v.getCoord().subtract(u.getCoord());
double myFr = fr(u,v,k);
v.setDisp(v.getDisp().add(delta.unit().scale((float)myFr)));
if(Double.isNaN(v.getDisp().getX())){
System.out.println("PANIC: "+u.getCoord().getX()+" "+u.getCoord().getY()+" "+delta.getX()+" "+v.getCoord().getX());
return;
}
}
}
}
for(int i = 0; i < nVertices; i++){
Node v = graphNodes.get(i);
for(int j = i+1; j< nVertices; j++){
Node u = graphNodes.get(j);
if(v.isAdjacent(u)){
Coordinates delta = v.getCoord().subtract(u.getCoord());
double myFa = fa(u,v,k);
v.setDisp(v.getDisp().subtract(delta.unit().scale((float)myFa)));
u.setDisp(u.getDisp().add(delta.unit().scale((float)myFa)));
}
}
}
for(int i = 0; i< nVertices; i++){
//actually adjusting the nodes
Node v = graphNodes.get(i);
if(i == 0){
System.out.println(v.getCoord().getX()+" "+v.getCoord().getY());
Coordinates disp = v.getDisp().unit().scale((float)Math.min(v.getDisp().length(), temperature));
System.out.println(">>"+disp.getX()+" "+disp.getY());
}
Coordinates newCoord = (v.getCoord().add(v.getDisp().unit().scale((float)Math.min(v.getDisp().length(), temperature))));
v.setCoord(newCoord.getX(), newCoord.getY());
// //prevent from going outside of bound
// float x = (float)Math.min(w, Math.max(0,v.getCoord().getX()));
// float y = (float)Math.min(h, Math.max(0, v.getCoord().getY()));
//
// v.setCoord(x,y);
if(i == 0){
System.out.println(v.getCoord().getX()+" "+v.getCoord().getY());
}
}
temperature *= 0.9;
System.out.println("TEMPERATURE = "+temperature);
}
for(int i = 0; i< nVertices; i++){
Node v = graphNodes.get(i);
System.out.println(v.getCoord().getX()+" "+v.getCoord().getY());;
}
}
private double fa(Node ni, Node nj, double k){
double distance = ni.getCoord().distance(nj.getCoord());
return distance*distance/k;
}
private double fr(Node ni, Node nj, double k){
double distance = ni.getCoord().distance(nj.getCoord());
return k*k/(distance+0.000001);
}
public static void main(String[] args){
MyGraph grph = new MyGraph();
grph.setBoundx(480);
grph.setBoundy(480);
grph.setC(1);
grph.randomGenerating(1);
grph.frLayout();
}
}
Apologies for the overly long question. I tried tutorials on net, but couldn't get anywhere closer to figuring out what's going wrong. Note that when finding unit vector, if a vector is zero (0,0), I make it a very small, non-zero vector so that when two vertices are close to one another, they will repel violently just as the author of the algorithm hoped.
Any instructions would be appreciated.
I found my bug. I was taking square root of the distance twice while computing the attraction and repulsion forces as well as a few other smaller bugs. I posted the corrected code in my question. Hopefully anyone out there attempting this algorithm will find it useful. Note that by removing the boundary, we let the graph free to evolve, it could produce better shape. Once obtaining the resulting graph, we could always translate/scale it so that it fit into whatever dimension required.
I have this problem: build a tower formed with n colored cubes with given side. There can't be a cube with a small side on a cube with a bigger side and neither can't be two neighbor cubes with the same color. I'm trying to solve it using Ant Colony Optimization. The trouble that I have with it is that I don't know how to choose the next cube to move the ant on and leave pheromone on it.
Example: For the following cubes:
C1 - side = 5, Color = Red
C2 - side = 2, Color = Green
C3 - side = 10, Color = Blue
C4 - side = 1, Color = Red
the solution would be: C3, C1, C2, C4
This is what I've done so far:
Ant class:
public class Ant {
private int[] visited;
private int size;
public Ant(int size) {
this.size = size;
this.visited = new int[size];
}
public void clearVisited(){
for(int i=0; i < size; i++){
visited[i] = -1;
}
}
public void visit(int index, int cube) {
visited[index] = cube;
}
public int visited(int index){
return visited[index];
}
public boolean contains(int cube){
for(int i=0; i < size; i++){
if(visited[i] == cube){
return true;
}
}
return false;
}
}
Cube class:
public class Cube {
private int length;
private String color;
public Cube(int length, String color){
this.length = length;
this.color = color;
}
public Cube(String color){
this.length = (int)Math.round(Math.random() * 200);
this.color = color;
}
public int getLength(){
return this.length;
}
public String getColor(){
return this.color;
}
public void setLength(int length){
this.length = length;
}
public void setColor(String color){
this.color = color;
}
public String toString(){
String str = "";
str += "Cub: l = " + length + ", " + "c = " + color;
return str;
}
public boolean equals(Object o){
if(o == null){
return false;
}
if(!(o instanceof Cube)){
return false;
}
Cube c = (Cube)o;
if((c.getColor().equals(this.getColor())) && (c.getLength() == this.getLength())){
return true;
}
return false;
}
}
Cube Repository class: here I store the cubes
public class CubeRepository {
private static ArrayList<Cube> availableCubes = new ArrayList<Cube>();
public static void addCube(Cube cube){
if(!availableCubes.contains(cube)){
availableCubes.add(cube);
}
}
public static Cube getCube(int index){
return availableCubes.get(index);
}
public static int getSize(){
return availableCubes.size();
}
}
The ACO algorithm:
public class ACO {
private int nrAnts;
private int nrCubes;
private Ant[] ants;
private int currentIndex;
private double[] pheromoneTrail;
private double ph = 1; //pheromon trace on every cube at start
private int alpha = 1;
private int beta = 5;
private int Q = 500;
private double q0 = 0.01;
public ACO(int nrAnts, int nrCubes){
this.nrAnts = nrAnts;
this.nrCubes = nrCubes;
ants = new Ant[nrAnts];
pheromoneTrail = new double[nrCubes];
}
public void createAnts(){//creeaza toate furnicile
currentIndex = 0;
for(int i=0; i < nrAnts; i++){
ants[i] = new Ant(nrCubes);
}
}
public Ant getAnt(int index){//return an ant
return ants[index];
}
public void setupPheromoneTrail(){ //sets pheromone trail for every cube at start
for(int i=0; i < nrCubes; i++){
pheromoneTrail[i] = ph;
}
}
public void placeAnts(){ //place every ant on a cube
for(int i=0; i < nrAnts; i++){
ants[i].visit(currentIndex, (int)(Math.random() * nrCubes));
}
currentIndex++;
}
public int selectNextCube(Ant ant){
if(Math.random() < q0){
int cube = (int)(Math.random() * nrCubes); //pick a random cube
while(!ant.contains(cube)){
if(CubeRepository.getCube(ant.visited(currentIndex-1)).getColor().equals(CubeRepository.getCube(cube).getColor())){
cube = (int)(Math.random() * nrCubes);
}
}
return cube;
}
return 1; //I didn't return a proper value
}
public void MoveAnts(){ //move every ant on another cube
while(currentIndex < nrCubes){
for(int i=0; i < nrAnts; i++){
ants[i].visit(currentIndex, selectNextCube(ants[i]));
}
currentIndex++;
}
}
}
Without having understood the whole program (it's far too much to quickly read it and find an answer): You may select a random cube that has a different color than the previous one with a pseudocode like this
private static final Random random = new Random(0);
public int selectNextCube(Ant ant)
{
Cube previousCube = CubeRepository.getCube(ant.visited(currentIndex-1));
List<Cube> allCubes = obtainAllCubesFromCubeRepository();
List<Cube> sameColor = obtainAllCubesWithSameColorAs(previousCube);
allCubes.removeAll(sameColor);
// EDIT>>>: You might also need this:
allCubes.remove(computeAllCubesAlreadyVisitedBy(ant));
// <<<EDIT: You might also need this:
int index = random.nextInt(allCubes.size());
Cube nextCube = allCubes.get(index);
return indexFor(nextCube);
}
BTW: I'd strongly recomment to not use Math.random(). It returns an unpredictable random value. Debugging a program that involves Math.random() is horrible. Instead, you should use an instance of java.lang.Random, as shown in the above snippet. You may call random.nextDouble() in order to obtain double values like with Math.random(). Additionally, you may call random.nextInt(n) to obtain int values in the range [0,n). The most important thing is: When you create this instance as new Random(0) then it will always return the same sequence of random numbers. This makes the program predictable and makes it possible to really debug the program. (If you want an "unpredictable" random number sequence, you can instantiate it as new Random(), without a random seed).
I am stuck trying to manager a list of list of lists. I have declared and initialized my data structure as so:
List<Vector<ArrayDeque<Vector_t>>> mData = new ArrayList<Vector<ArrayDeque<Vector_t>>>(
6);
for (int i = 0; i < 6; ++i) {
mData.add(i, new Vector<ArrayDeque<Vector_t>>());
// mData.get(i).setSize(200);
}
for (int i = 0; i < 6; i++) {
for (int k = 0; k < 200; k++) {
mData.get(i).add(new ArrayDeque<Vector_t>());
mData.get(i).get(k).add(new Vector_t());
}
}
where Vector_t is:
class Vector_t {
float x;
float y;
float z;
}
Is this initialization correct? When adding values to the array deque at the last position, it replaces the whole arraydeque with the last element, and I have no idea why.
Also, when I changing values using the code mdata.get(1).get(42) the element at mdata.get(0).get(40) is also affected. Again, I have no idea why?
I have given hardcoded values for example..this is the way i m adding
if (mData.get(dir.value).get(slice).size() >= sMaxNum_c)
{
mData.get(dir.value).get(slice).removeFirst();
}
mData.get(dir.value).get(slice).addLast(result.acc);
when adding values to one direction other direction values are changing...:(
Please help me to solve this.
My suggestion would be to either introduce some classes as Amir suggested, or at least make your code easier to understand by introducing some well-named, temporary local variables.
I don't know what you're trying to acheive, but re-writing with the use of some local variables might allow you to spot an issue:
List<Vector<ArrayDeque<Vector_t>>> mData = new ArrayList<Vector<ArrayDeque<Vector_t>>>(
6);
for (int i = 0; i < 6; ++i) {
mData.add(i, new Vector<ArrayDeque<Vector_t>>());
}
for (Vector nextVector : mData) {
for (int k = 0; k < 200; k++) {
ArrayDeque<Vector_t> tempArray = new ArrayDeque<Vector_t>());
tempArray.add(new Vector_t());
nextVector add(tempArray);
}
}
I am not sure of what you are trying to achieve, but for starters, you should consider using another Data Structure besides Vector as it is obsolete.
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
// Consider using another DataStructure such as Arraylist, as Vector<> is obsolete.
import java.util.Vector;
public class main {
public static void main(String[] args) {
// Use diamond inference.
List<Vector<ArrayDeque<Vector_t>>> mData = new ArrayList<>(6);
for (int i = 0; i < 6; i++) {
Vector<ArrayDeque<Vector_t>> vav = new Vector<>();
ArrayDeque<Vector_t> av = new ArrayDeque<>();
for (int k = 0; k < 200; k++) {
av.add(new Vector_t(2.0f, 2.0f, 2.0f));
}
vav.add(av);
}
}
}
Use variables instead of calling get() so much.
public class Vector_t {
private float x;
private float y;
private float z;
public Vector_t() {
x = 0.0f;
y = 0.0f;
z = 0.0f;
}
public Vector_t(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
}
public float GetX() {
return x;
}
public float GetY() {
return y;
}
public float GetZ() {
return z;
}
public void SetX(float x) {
this.x = x;
}
public void SetY(float y) {
this.y = y;
}
public void SetZ(float z) {
this.z = z;
}
}
use setters and getters for your class, it's all about using OOP programming concepts :)
If you are a little more specific on what you are trying to accomplish, I am sure we could help.
-Francisco