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
Auto Buy Store : https://utchiha-market.mysellauth.com/
Not sure if we’re legit? Check Our server — real reviews, real buyers
https://discord.gg/4EPpYhe2HA | https://campsite.bio/utchihaamkt
I spent a lot of time transferring the UI from the original. I won't describe all the elements yet. But I'm very close to fully transferring all the basic windows. I'll leave this video here as an example.
In this video I check the work of the skills window. The server sends different lists, I immediately send them to update in SkillList
True value lies in people
We believe that a service is not only about functions, but about the people who use it.
For us, it’s important that working with numbers is simple and convenient, so you can solve your tasks with peace of mind.
We improve the service every day: making it more stable, adding new features, and ensuring everything works as it should.
We want working with Vibe SMS to be enjoyable, and for you to feel like part of the team, not just a client.
Vibe SMS is not only about service, but about the atmosphere where it’s comfortable and easy to work.
Website: https://vibe-sms.net/
Telegram: https://t.me/vibe_sms
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