You need to sign in to do that
Don't have an account?
Gunish Rai Chawla
Native Stack Data Structure
Hi All,
We are trying to build a tree trversal method in apex, in salesforce and for DFS we need to access a native data structure of a Stack?
Is this structure available directly or has anyone tried to custom implement a stack ?
Thanks in advance,
Gunish
Roger Wicki
There is no such data structure as a stack in Salesforce. However, it is pretty simple to set up an own model of a stack.
Roger Wicki
Here you go. This Stack offers all functions a native java Stack offers and works with both, Objects and sObjects. Of course you need a test class to get the Code Coverage for it. Here are two methods, one for an Object (String in this case) and one for an sObejct(Account in this case):
Note: I defined my Stack class as an inline class of "ArcUtil" where I keep (static) everyday helper methods and classes like this one.