I have a problem that i cant get over. Lets say i have a list of numbers with no particular pattern for example <> [3, 5, 8, 15, 18, 22] I have a method for retrieving the numbers and matching it to other numbers, For example: Code: Increasing number : List numbers 1 2 3 : 3 4 5 : 5 ... 7 8 : 8 So it basically matches a number increasing by 1 with the numbers in the list. My problem seems to be that is the increasing numbers were to exceed the max number in the list (in this case 22), how do i get the appropriate number in the list For example it exceeds 22 Code: Increasing number : List numbers 22 23 24 25 : 3 So it would 'go back' to the start of the list and start counting from there again Things i have tried so far: ( nothing worth mention) Any help would be appreciated, maybe im thinking about this too hard (or not at all) Thanks
What's the point of all this? What are you attempting to accomplish by doing this? http://xyproblem.info/
@1Rogue Sorry my question is undeniably unclear I have a hashmap storing milestone to itemstacks. When a player kills, their streak increases. When their streak gets to a milestone they get the itemstacks But my problem is when the max number in the hashmap (the milestone) is exceeded. So if the max milestone was 20 and minimum was 5. And they get 25 streak, then they would get the itemstacks to the '5' milestone. So in other words after reaching the max number in the list, it goes back to the first. How do i this?
So essentially once you've hit the maximum value in your map, you want to reset? I would probably have a class that manages killstreaks for me, and retrieves the killstreak by using a modulo operation of "current kills" by "max killstreak": Code:java public class KillStreaks { private int max = 0; private final Map<Integer, KillStreak> streaks = new HashMap<>(); //Consider a MultiMap public void registerKillStreak(KillStreak ks) { int kills = ks.getRequiredKills(); //Assuming a method like this exists if (kills > this.max) { this.max = kills; } this.streaks.put(kills, ks); } public KillStreak getKillStreak(int kills) { return this.streaks.get(kills % this.max); } }