Raised This Month: $252 Target: $400
 63% 

ArrayList Class vs. ArrayStack Class


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FroGeX
Junior Member
Join Date: Aug 2020
Old 09-12-2020 , 04:26   ArrayList Class vs. ArrayStack Class
Reply With Quote #1

What is the difference between ArrayList and ArrayStack except that ArrayList has a little more functionality
FroGeX is offline
Scag
AlliedModders Donor
Previously known as:
Ragenewb
Join Date: May 2017
Location: Crashing Hale
Old 09-13-2020 , 01:04   Re: ArrayList Class vs. ArrayStack Class
Reply With Quote #2

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.
__________________
Over-engineering is underrated.

GitHub
Scag is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:38.


Powered by vBulletin®
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Theme made by Freecode