![]() |
|
[Java] Java List/Collections/Map something idk - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Java] Java List/Collections/Map something idk (/showthread.php?tid=5576986) |
Java List/Collections/Map something idk - Loses - Mar 16, 2017 I'm trying to find out if it's possible with the capabilities of Java, without having to right helper methods but rather do it in a few lines of code. So what I am looking for is essentially a list with a set amount of entries. So like Code int[] recentVisitors = new int[5];I essentially want to set the latestVisitor to recentVisitors[0] and move everyone ++ except for the last guy, which he would simply be GC'd. I UNDERSTAND that I can do this with my array. I was curious if Java has something that does this, I know there's a lot of shit that I don't know about so I am just trying to expand my knowledge. Thanks in advance, - Loses * - GenericSkid - Mar 16, 2017 Why not just use a stack or queue for this? I'm a little confused what you're trying to do, but one of these should be better fit for the job than an array. * - Loses - Mar 17, 2017 (Mar 16, 2017 08:44 PM)Lord Pankake Wrote: Why not just use a stack or queue for this? I'm a little confused what you're trying to do, but one of these should be better fit for the job than an array. (Mar 17, 2017 03:10 AM)Orka Wrote: I agree with Lord pancake, a stack is well suited. A stack, thanks. * - Stealthâ„¢ - Mar 18, 2017 Guava has a version of this called an EvictingQueue. * - nOrr - Mar 19, 2017 It sounds like you need a Queue of a fixed size. |