Author Topic: I32 Numbers Stack Include File for your Library  (Read 4049 times)

0 Members and 1 Guest are viewing this topic.

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1039
  • User-Rate: +30/-4
    • it-berater
I32 Numbers Stack Include File for your Library
« on: January 10, 2011, 08:57:25 AM »
What is a numbers stack?

Its just like a "Stack of Paper". You can put one thing at the Top and when you need it, you can remove it. Thats called "Push and Pop".

You PUSH something on the STACK, and you POP it off the Stack later.

There are places in Information scienece where you need a numbers stack.
If you parse Source code for example.

The CPU has their own Numbers Stack and PUSH and POP commands.
You may need one in your program for you own uses.
Here is one.

You can do the following usingthis

SUB I32_Push1(BYVAL dwVal AS DWORD)    ' Push ONE Number onto the Stack
SUB I32_Push2(BYVAL dwA AS DWORD,BYVAL dwB AS DWORD)  ' Push Two Numbers onto the Stack
FUNCTION I32_Pop() AS DWORD   ' POP one Number off the Stack
SUB I32_Swap() ' Swap the most upper Stack positions
SUB I32_Xap() ' Swap two Stack-Elements identified by their Index Position
SUB I32_Join(BYREF T01 AS STRING)   ' Put the whole Stack into a String
SUB I32_Unjoin(BYREF T01 AS STRING)  ' Get the whole Stack (back) out of a String
SUB I32_Clear()  ' Clear the Stack - start a new one.
SUB I32_Dump() ' Take a look on your Stack

Lets talk about Speed:
I get 1 Seconds for Pushing and Popping 800.000 Items.
Then to Join and Unjoin this resulting Stack with 400.000 Items for 10 times, i get here: 1 Second.

This way you can have unlimited Number of Stacks. Just Join one into a String,
keep it for later.
Then clear the Stack, use it in your Subprogram.
Clear it again, and Restore your Previous stack using Unjoin.
« Last Edit: January 10, 2011, 09:28:27 AM by Theo Gottwald »