Jacky Luk

Ranch Hand
+ Follow
since Aug 02, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
3
Received in last 30 days
0
Total given
135
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jacky Luk

Tushar Goel wrote:I dont think you can do this way. Probably you need store them in some collection and each time you are adding any element into it,
you need to compare that with all the values present the map.



So then I need to use a Map of ArrayList instead?
Thanks
Jack
8 years ago
Let's say I had 4 agents, which possess some values.
So In the first step, I consider using a Map
Then for all agents, all of these values must be unique
So
Agent 1
1,3,5
Agent 2
2,4,7
Agent 3
8,9,10
Agent 4
6,11,12
etc

But I just can't do the following

I wonder what is the correct way of doing it?
Thanks a lot
Jack
8 years ago
Okay, I've solved that

8 years ago


Thanks Pawel for your kindred help
Jack
8 years ago

Paweł Baczyński wrote:Your new comparator can never return a negative value.

So it violates this rule:
The implementor must ensure that sgn(compare(x, y)) == -sgn(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

What do you mean by repeated node? A node with the same coordinates as some other node?



Yes, not sure why there can be 2 nodes in the SortedSet with the same x and z coordinates.
the g values can be don't-care
Thanks
Jack
8 years ago
Hi Pawel,

I haven't got this working yet like this.


There are still repeated nodes....
Thanks
Jack
8 years ago


I've added some nodes to the SortedSet, in theory, the SortedSet shouldn't contain duplicate nodes
on my map, but the result isn't it. Why? There are still duplicate nodes on the map.
From each iteration of the function where it starts to add nodes to this SortedSet,
it even has been cleared as well. But I don't think I will make a difference.
Just wondering why are there duplicate nodes in my map?
Could anyone please lend me a hand?
Thanks
Jack
8 years ago

Stephan van Hulst wrote:If the key of the map is unrelated to the id of the unit, then you can't do this with your map. You should use different keys, or sort your values at a later stage.



Got it, thanks... I'll try the other way round.
Jack
8 years ago


I'd like to sort by Unit id first (where Unit has an id which is an Integer), then sort by the String value
The String values have the format of 0:0:0 where 0s are integers.
Thanks
Jack
8 years ago
I want to shuffle the keys within this data structure along with the values




I can shuffle a list like this


But How do I do the same for the Map container?
Thanks a lot
Jack
8 years ago
dodgedLoc should not be changing.
But for the backup path, there will be something added to it every now and again.
How to avoid dodgedLoc to change when the backup path is changed also.
The container is by reference, how can I just make a copy of it?
Thanks
Jack

8 years ago
Hello there,
I have changed to String as keys, and it works well.
But I've got a new question.
How do I design the algorithm such as the following happens

I can use a SortedSet for that, but now I want to count how many occurrencies happen
for 1:1, 1:2 etc after the Set has been filtered. (The second and the third keys)
How can I do that?
Thanks
Jack
8 years ago

All occurrencies happen to be one only no matter they have repeated several times.
Any ideas why?
Thanks
Jack

8 years ago


I want to mock this using one of HttpURLconnection, HttpPost of this sort....
How can I do that?
Any examples?
Thanks
Jack
9 years ago