1. rant // explain std/stack.e to me

First Item:

Does anyone north (or south) of the Mississippi use FILO instead of LIFO?

FIFO :: first in first out 
 
LIFO :: last in first out 
 
FILO :: first in last out 
 

Addition: could use an extra constant value in std/stack.e because of how language is used.

Second Item:

What is the value of using this standard library?

Using push and pop results in a big performance penalty.

_tom

include std/stack.e 
 
 
-- a standard list of items  
-- to be pushed onto the stack  
-- and then popped 
atom size = 10_000 
sequence raw_data = repeat( 1000, size ) 
raw_data = rand( raw_data ) 
 
atom t 
 
------------------ using just a sequence 
                   -->> 0 seconds 
t = time() 
 
        -- create a "stack" 
        sequence MYfifo = {} 
 
        -- push items on the "stack" 
        for i = 1 to size do 
            MYfifo = append( MYfifo, raw_data[i] ) 
        end for 
 
        -- pop items off the "stack" 
        while length(MYfifo) > 0 do 
            object item = MYfifo[$] 
            MYfifo = MYfifo[1..$-1] 
        end while 
 
printf(1, "\n MYfifo %g \n", time() - t ) 
 
 
------------------------- using the standard library 
                        -->> 0.23 seconds 
t = time() 
 
        -- create 
        stack OEfifo = new( FIFO ) 
     
        -- push 
        for i=1 to size do 
            push( OEfifo, raw_data[i] ) 
        end for 
 
        -- pop 
        while not is_empty(OEfifo) do 
            pop( OEfifo ) 
        end while 
 
printf(1, "\n OEfifo %g \n", time() - t ) 
 
new topic     » topic index » view message » categorize

2. Re: rant // explain std/stack.e to me

_tom said...

Does anyone use FILO instead of LIFO?

Well, the stack of plates in the cupboard above my kitchen sink is definitely filo...

_tom said...

Using push and pop results in a big performance penalty.

------------------ using just a sequence 
                   -->> 0 seconds 
------------------------- using the standard library 
                        -->> 0.23 seconds 

Ouch. Thankfully I don't use that.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu