Hello guys, I'm here with a new code I'm trying to make that I cannot get it out of my head :rage: So, here's my problem: I have two tables with information. Both of them have the same structure (ID, Value) but one of them has more repeated values than the other one. For example: |----------------------| |----------------------|
| ID Val | | ID Val |
|----------------------| |----------------------|
| 1 0 | | 1 0 |
| 1 0 | | 1 0 |
| 2 5 | | 1 0 |
| 2 5 | | 1 0 |
| 2 5 | | 2 5 |
| 2 5 | | 2 5 |
| 3 1 | | 2 5 |
| 3 1 | | 2 5 |
----------------------- | 3 1 |
| 3 1 |
------------------------
Here you can see two tables with the same structure but one of them has more repeated values than the other one (as I said before). What I'm trying to make, is the following: take the ID from the first table (ID = 1) and copy the value from the second table (Val = 0), but just copy it as many times as the ID in the first table exists. For example: if the ID 1 in the first table exists 2 times, copy the Val from the second table 2 times, skip the other two, and go to the next ID by doing the same.
I've tried to do it. The class I've made loads both tables and fills two ArrayLists with its information by putting them into an IntIntHolder class (thks aCis) in order to compare them later. So far, this is the code I've written, but it throws NoSuchElementException. And running it without the (see below), it prints some data but not all (if total data is 8, it prints 4).
while (elementA.getId() != elementB.getId())
Here's my code:
public void compareAndPrint()
{
Iterator<IntIntHolder> iterA = listA.iterator();
Iterator<IntIntHolder> iterB = listB.iterator();
while (listA.hasNext())
{
IntIntHolder elementA = iterA.next();
IntIntHolder elementB = iterB.next();
if (elementA.getId() == elementB.getId())
System.out.println(elementB.getValue());
else
{
while (elementA.getId() != elementB.getId())
iterB.next();
}
}
}
So ye... that's all. I'm trying to parse some data from the system so that's why I'm trying to do this.
Thanks for reading, and I'm looking forward to your answers!
DISCORD :
utchiha_market
telegram :
https://t.me/utchiha_market
SELLIX STORE :
https://utchihamkt.mysellix.io/
Join our server for more products :
https://discord.gg/hood-services
https://campsite.bio/utchihaamkt
hello everyone !
I need help with a l2script Rev H5-Salvation/Classic build. I compiled the project, installed everything but I can't log in to the server, it won't log me in. I tried a thousand ways without good results. I leave you the error when logging in either with the H5-Salvation Client.
ERROR ---> WARN: IPBANMANAGER ---> IP !!!!
I'm waiting for help! Thank you!
Question
Alianza
Hello guys,
I'm here with a new code I'm trying to make that I cannot get it out of my head :rage:
So, here's my problem: I have two tables with information. Both of them have the same structure (ID, Value) but one of them has more repeated values than the other one. For example:
|----------------------| |----------------------|
| ID Val | | ID Val |
|----------------------| |----------------------|
| 1 0 | | 1 0 |
| 1 0 | | 1 0 |
| 2 5 | | 1 0 |
| 2 5 | | 1 0 |
| 2 5 | | 2 5 |
| 2 5 | | 2 5 |
| 3 1 | | 2 5 |
| 3 1 | | 2 5 |
----------------------- | 3 1 |
| 3 1 |
------------------------
Here you can see two tables with the same structure but one of them has more repeated values than the other one (as I said before). What I'm trying to make, is the following: take the ID from the first table (ID = 1) and copy the value from the second table (Val = 0), but just copy it as many times as the ID in the first table exists. For example: if the ID 1 in the first table exists 2 times, copy the Val from the second table 2 times, skip the other two, and go to the next ID by doing the same.
I've tried to do it. The class I've made loads both tables and fills two ArrayLists with its information by putting them into an IntIntHolder class (thks aCis) in order to compare them later. So far, this is the code I've written, but it throws NoSuchElementException. And running it without the (see below), it prints some data but not all (if total data is 8, it prints 4).
Here's my code:
So ye... that's all. I'm trying to parse some data from the system so that's why I'm trying to do this.
Thanks for reading, and I'm looking forward to your answers!
7 answers to this question
Recommended Posts