Jump to content
  • 0

Fastlist -> Arraylist Acis


Question

Posted (edited)

http://imgur.com/a/1oYgm

protected int getWinnerTeam()
	{
		ArrayList<EventTeam> t = new ArrayList<>();
		
		for (EventTeam team : teams.values())
		{
			if (t.size() == 0)
			{
				t.add(team);
				continue;
			}
			
			if (team.getScore() > t.getFirst().getScore())
			{
				t.clear();
				t.add(team);
				continue;
			}
			
			if (team.getScore() == t.getFirst().getScore())
				t.add(team);
		}
		
		if (t.size() > 1)
			return 0;
		
		return t.getFirst().getId();
	}

getFirst () must be replaced by what?

Edited by L2shaken

Recommended Posts

  • 0
Posted (edited)

http://imgur.com/a/gZoEQ

protected L2PcInstance getPlayerWithMaxScore()
	{
		L2PcInstance max = players.head().getNext().getKey();
		
		for (L2PcInstance player : players.keySet())
			if (players.get(player)[2] > players.get(max)[2])
				max = player;
		
		return max;
	}
	

And this error, how can I solve it?

Edited by L2shaken
  • 0
Posted (edited)

can you help me?

Noone will help u if u cannot help ur self ...

Review thats what u "wrote",and ask urself how u can get the max score ...

 

I m not sure if head() supposed to be the head of the collection ,also i m not sure if the code will work but u can google and learn what head/tail is :).

Edited by bravetobe
  • 0
Posted

Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D

  • 0
Posted (edited)

Just hire AccessDenied to implement head() method to the HashMap, nothing is impossible when AccessDenied is here. ;D

so he wants to get the head from the hashmap or the player with the max score?

both laughable... or at least the 1 

but wait... that dude leeches only

 

I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao.

Edited by bravetobe
  • 0
Posted

so he wants to get the head from the hashmap or the player with the max score?

both laughable... or at least the 1 

but wait... that dude leeches only

 

I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao.

What is this head :'( and what is this hashmap :'( ? Help me :/

  • 0
Posted

so he wants to get the head from the hashmap or the player with the max score?

both laughable... or at least the 1 

but wait... that dude leeches only

 

I will grab some popcorn and keep an eye in this topic and how he will actually do (head) that lmao.

AccessDenied can find the head, the tail, and wahtever you want in a HashMap... ;D

 

1000$ and done.

A very reasonable price! :lol:

  • 0
Posted (edited)
EventTeam winner = null;
for (EventTeam team : teams.values())
      if (team.getScore() > ((winner == null) ? 0 : winner.getScore()))
             winner = team;


return winner;

If you got only 2 teams max, forever, it's easier to simply write both teams and compare team1 and team2 getScore().

 

If you can't complete or integrate what I wrote, simply forget to open a server for the next 6 months minimum and take time to learn Java.

 

PS : it's generally terrible to return a simple id, which means you must find back the associated team in one way or another after the getWinner(). It's far better then to take back the entire EventTeam which probably holds all useful informations, such as team compo, the score, the id, etc.

 

PS2 : I avoid to use or provide lambdas writting style, first because I don't want to seek the best writting style, second because lambdas is still shady for 90% of ppl, similar to maven vs ant, third because it's the most popular writting style and at least anyone will understand it.

Edited by Tryskell

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Only 3 days left and we'll start with some events, you can check our Discord for more info!
    • Tired of frantically switching between windows trying to find that specific Warlock who should be casting saves? Forgot which server you left your Warsmith on? This mod solves these problems! What it does: Turns the boring window title into an information panel: Server Name - Character Name [Class] Real-life examples: - ServerName - HardcoreFarm [Spoilerr] (who's been spoiling for 3 months already) - ServerName - ClericHelper [Buffer] (eternal buffer on standby) - ServerName - MainChar [Gladiator] (main character who's always AFK) Why you need this: For multiboxers - to avoid confusing where the DD is and where the healer is For the forgetful - if your memory is like a goldfish For streamers - viewers immediately see who's on screen For adults - when playing at work and need to quickly hide the window DLL only - no Interface files needed Installation (more complicated than making tea): 1. Download the DLL 2. Drop it into the System folder 3. Launch the client 4. Be amazed how you lived without this before! Purchase Conditions: Price: 100$ Payment Method: USDT. How to Buy: Contact me on Telegram: @kiselevwv for a quick response. I will answer all your questions and provide additional information if needed. I guarantee functionality at the moment of sale and prompt assistance with setup after purchase.
    • I agree, l2damage crap to compare to l2java which was the father of pvp servers and till this days people playing there for good time.
    • 📝 Registration — Account Registration Creating a new player account. Usually includes: login password password confirmation email Result: a new record is created in the accounts table (loginserver). 🔑 Change Password — Password Change The player changes the password knowing the current one. Required: current password new password new password confirmation Result: the password field is updated in the accounts table. ♻️ Password Recovery — Password Reset If the player forgot the password. Implementation only via email: the player enters their login, email the system sends an email with a link or code the player opens the link / enters the code sets a new password Result: the password is updated in the accounts table.   All fields are validated (required, format, length, uniqueness, security checks).   Price: 80$   and i can rewrite script for PTS server.   Contacts:   Telegram Discord
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..