Raised This Month: $12 Target: $400
 3% 

ArrayList Class vs. ArrayStack Class


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FroGeX
Senior 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
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
BTC
ETH

Retired
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 12:57.


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