AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   ArrayList Class vs. ArrayStack Class (https://forums.alliedmods.net/showthread.php?t=327323)

FroGeX 09-12-2020 04:26

ArrayList Class vs. ArrayStack Class
 
What is the difference between ArrayList and ArrayStack except that ArrayList has a little more functionality

Scag 09-13-2020 01:04

Re: ArrayList Class vs. ArrayStack Class
 
The most fundamental difference is that an ArrayStack items are FILO/LIFO and ArrayList items can be retrieved/inserted at any index.

Internally, they're exactly the same, an ICellArray. So the question is, why bother with a stack?

When you declare/use either, you are stating what kind of behavior you want. An ArrayList behaving as an ArrayStack is unneeded complexity.

You are telling anyone who looks at your code (including your future self) what it is you are doing and intend to do with this array.

If you want to stretch it, the same argument could be made about private class members/methods. Why bother making something private? Which presents the above answer of enforcing behavior and managing complexity.

Contrary to my signature, I tend to "use the minimum to achieve the maximum" when I code.

FWIW there's also a Queue include you can check out and use.


All times are GMT -4. The time now is 15:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.