r/JavaProgramming • u/CRAMATIONSDAM • Sep 12 '24
How submitting using “Pair” in Java is faster than direct assignments?
/r/IT_Computer_Science/comments/1fevgl4/how_submitting_using_pair_in_java_is_faster_than/0
Sep 12 '24
[deleted]
1
u/CRAMATIONSDAM Sep 12 '24
yes
0
Sep 12 '24
[deleted]
1
u/CRAMATIONSDAM Sep 12 '24
Thanks for replying my question but the answer is not satisfactory i am in the search of it if i find the answer then i will post here. 😊
0
Sep 12 '24
[deleted]
1
u/CRAMATIONSDAM Sep 12 '24
oh a student have a lot of time waste Let's see if i find something.
1
u/CRAMATIONSDAM Sep 12 '24
Here if found out why this is faster.
jfx/modules/javafx.base/src/main/java/javafx/util/Pair.java at master · openjdk/jfx · GitHub
it is using the hash table technique.
Which makes it more faster than assignment.
means that is also interesting that fetching a value form table is more faster than assignment in this case. if any other knowledge you have please post......
waiting..
1
Sep 13 '24
[removed] — view removed comment
1
u/CRAMATIONSDAM Sep 13 '24
Hash table technique in Pair CODE if you see The Pair class it is using hash table technique key value Pairs. And in Pair class a table is maintained in the code of Pair class just open the link provided and see the code of Pair class it uses <K,V> way to manage the data. Pair class is implemented like hash tables not exactly a hash table.
1
u/CRAMATIONSDAM Sep 13 '24
Now if any thing is not understandable still it can be explained and if you do not know about hash table there is a difference between hashing and hash tables. I hope it helps. 🙂
→ More replies (0)1
Sep 13 '24
[removed] — view removed comment
1
1
u/CRAMATIONSDAM Sep 13 '24
Okay wait I will send.. check please here https://www.naukri.com/code360/problems/swap-two-numbers_1112577
1
u/Typical_Ad_6436 Sep 13 '24
How is the input recieved in your code? Are the numbers read from stdin or as arguments? Either way, I am after the memory work you are doing. Are you allocating two arrays, whereas the Pair solution allocates two Pair objects - before calling the described methods?