Dunno if anyone remembers these from AmiBlitz, but it makes working with large linked lists a lot quicker if you need to swap to another element and then back to the old one again.
Basically, just push the current element pointer on the stack, SelectElement() to another part of the list, get/set some info, then pull the old element pointer back again.
I know this can already be already be done with SelectElement(mylist(),old_index) , but doesn`t PB have to start from the first element and work up the list until the right element is found ?
[Implemented] LinkedList: PushElement+PullElement
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
I requested to Fred PushElement() and PopElement() for PB time ago (before PB forums exist, via email), just like Amiga BlitzBasic 2 commans: PushItem() and PopItem().
But in fact, MrMat gave the answer: it can be done with only a unique command in PB: ChangeCurrentElement().
Previously saving the current element pointer in a variable before change it.
But in fact, MrMat gave the answer: it can be done with only a unique command in PB: ChangeCurrentElement().
Previously saving the current element pointer in a variable before change it.

- tinman
- PureBasic Expert
- Posts: 1102
- Joined: Sat Apr 26, 2003 4:56 pm
- Location: Level 5 of Robot Hell
- Contact:
Unless you implement some other stack on top of ChangeCurrentElement() then it's not quite the same as Push/PopItem. You had the ability to stack 8 (IIRC) items at the same time from the list.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
(WinXPhSP3 PB5.20b14)
-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
-
- Enthusiast
- Posts: 767
- Joined: Sat Jan 24, 2004 6:56 pm
I can live with that.okasvi wrote:better:
add&get
I don't see a big difference between 'insert' and 'add' either way, although 'add' surely is a bit more generic, which must be a good thing.
Your 'get' is definitely better, because my 'remove' seems to imply that the prior content is lost after 'removing' it. It's not, of course, it's merely transferrred to another variable, so that's why I like 'get' better. Thanks for your input...