Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NeoCL v1.1b has been released!
#21
I still don't quite understand why people prefer the inferior LZW to the far superior LZ77...
I'd knock on wood, but my desk is particle board.
Reply
#22
*looks at LZ77*

Ah... :roll: Maybe I'll implement it some time... just don't expect it to be implemented tomorrow Wink
Reply
#23
I tried the new version with the Canterbury corpus, as i promised.

It made a file of 1434867 bytes, that makes a 51% of the original size!!

It's curious it used LZW for all files except for the Excel sheet, where it prefered a brew of differnt methods..

A suggestion. Powers of two are used in many routines. You should precalc an array of powers of 2. This way you would avoid floating point calcs in the compression routines, and everything would be much faster.
Antoni
Reply
#24
Quote:(aw Oracle, why didn't you finish StatLib? Wink)

Sorry Smile. Maybe in the far-off future (or if someone invents LinkedLists for QB...)
Reply
#25
Neo: Cool Stuff!!!!

Oracle: v1ctor did a pseudo-linked list structure in QB. :*)(
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#26
hmm...you can using the array implementation of linked lists. Its very simple.
Reply
#27
Quote:Neo: Cool Stuff!!!!

Oracle: v1ctor did a pseudo-linked list structure in QB. :*)(

Really? I'm interested, do you know where the code is?

TBBQ: It's not as easy as you'd think: You still have to think about issues as tombstones, resizing the array, what about self-organizing, merging a list with another, and of course QB memory/array limits etc. Although I've just spent all year working out how such things would be done in Java (things are so much easier with pointers...), things may be a little more tricky using arrays in QB...
Reply
#28
I'm posting the code here as i'm getting a "Internal Server Error" at bad-logic's forum when i try reply to your msg, weird..

-----------------------------

Sure, i used it in most of CS2D's modules, it's limited 'coz if there's no enough space, it will simply skip a new node being added.. that's ok for games, but with other algos.. redim preserve would help. (to get the code to compile with qb 4.5, delete the byval's)


queue.bas:

Code:
Option Explicit

DefInt a-z
'$include: 'queue.bi'


'':::::
Sub listInit( l as TLIST, lTB() as LNODE, byval maxnodes as integer )
    Dim i as integer

    ReDim lTB( 0 to maxnodes-1 ) as LNODE

    '' put all into the free list
    For i = 0 to maxnodes-1
        lTB(i).prv = i-1
        lTB(i).nxt = i+1
    Next i
    lTB(maxnodes-1).nxt = -1

    l.fhead    = 0
    l.head     = -1
    l.tail     = -1
    l.nodes    = maxnodes

End Sub

'':::::
Sub listEnd( l as TLIST, lTB() as LNODE )

    erase lTB

    l.head     = -1
    l.tail     = -1
    l.nodes    = 0

End Sub

'':::::
Sub listClear( l as TLIST, lTB() as LNODE )
    Dim i as integer

    For i = 0 to l.nodes-1
        lTB(i).prv = i-1
        lTB(i).nxt = i+1
    Next i
    lTB(l.nodes-1).nxt = -1

    l.fhead = 0
    l.head     = -1
    l.tail     = -1

End Sub

'':::::
Function listAdd%( l as TLIST, lTB() as LNODE, byval idx as integer ) Static
    Dim n as integer, nn as integer, i as integer

    ''
    listAdd = -1

    '' take from free list
    if( l.fhead = -1 ) then
        exit function
    end if

    n = l.fhead
    nn = lTB(n).nxt
    l.fhead = nn
    if( nn <> -1 ) then
        lTB(nn).prv = -1
    end if

    '' add to used list
    lTB(n).idx     = idx
    lTB(n).prv    = l.tail
    lTB(n).nxt    = -1

    If( l.tail <> -1 ) Then
        lTB(l.tail).nxt = n
    else
        l.head = n
    End if

    l.tail = n

    ''
    listAdd = n

End Function

'':::::
Sub listDel( l as TLIST, lTB() as LNODE, byval n as integer ) Static
    Dim pn as integer, nn as integer

    '' delete from used list
    pn = lTB(n).prv
    nn = lTB(n).nxt
    If( pn <> -1 ) Then
        lTB(pn).nxt = nn
    Else
        l.head = nn
    End if

    If( nn <> -1 ) Then
        lTB(nn).prv = pn
    Else
        l.tail = pn
    End if

    '' add to free list
    nn = l.fhead
    lTB(n).prv = -1
    lTB(n).nxt = nn
    if( nn <> -1 ) then
        lTB(nn).prv = n
    end if
    l.fhead = n

End Sub

'':::::
Function listGetFirst%( l as TLIST, lTB() as LNODE ) static

    listGetFirst = -1

    l.curr = l.head
    if( l.curr = -1 ) then Exit Function

    listGetFirst = lTB(l.curr).idx

end function

'':::::
Function listGetNext%( l as TLIST, lTB() as LNODE ) static

    listGetNext = -1

    if( l.curr = -1 ) then Exit Function

    l.curr = lTB(l.curr).nxt
    if( l.curr = -1 ) then Exit Function

    listGetNext = lTB(l.curr).idx

end function

queue.bi:

Code:
type TLIST
    head    as integer
    tail    as integer
    fhead    as integer
    nodes    as integer

    curr    as integer
end type

Type LNODE
    idx        as integer
    prv        as integer
    nxt        as integer
End Type


declare Sub         listInit        ( l as TLIST, lTB() as LNODE, byval maxnodes as integer )

declare Sub         listEnd            ( l as TLIST, lTB() as LNODE )

declare Sub         listClear        ( l as TLIST, lTB() as LNODE )

declare Function     listAdd%        ( l as TLIST, lTB() as LNODE, byval idx as integer )

declare Sub         listDel            ( l as TLIST, lTB() as LNODE, byval n as integer )

declare Function     listGetFirst%    ( l as TLIST, lTB() as LNODE )

declare Function     listGetNext%    ( l as TLIST, lTB() as LNODE )


usage example:

Code:
'$include: 'queue.bi'

const MAXITEMS%        = 100

type ITEM
    id            as integer
    stat        as integer
    
    ln            as integer                        '' linked-list node
end type


'' globals
dim shared itemlist as TLIST

redim shared itemTB( 0 ) as ITEM

redim shared lTB( 0 ) as LNODE


''::::
sub itemInit
    dim i as integer

    redim itemTB( 0 to MAXITEMS-1 ) as ITEM

    listInit itemlist, lTB(), MAXITEMS

    '' set to invalid
    for i = 0 to MAXITEMS-1
        itemTB(i).ln = -1
    next i

end sub

''::::
sub itemEnd

    erase itemTB

    listEnd itemlist, lTB()

end sub

'':::::
function newItem% static
    static i as integer
    dim ln as integer

    if( itemTB(i).ln <> -1 ) then
        listDel itemlist, lTB(), itemTB(i).ln
        itemTB(i).ln = -1
    end if

    '' find a free slot
    ln = listAdd( itemlist, lTB(), i )
    if( ln = -1 ) then
        newItem = -1
        exit function
    end if

    '' save list node for fast deletion later..
    itemTB(i).ln = ln

    newItem = i

    '' this will only work if nodes are always deleted after being used
    i = (i + 1) mod MAXITEMS

end function


'':::::
sub itemAdd( byval id as integer, byval stat as integer ) static
    dim i as integer

    i = newItem
    if( i = -1 ) then exit sub

    '' save
    itemTB(i).id = id
    itemTB(i).stat = stat
    
end sub

''::::
sub itemUpdateAll static
    dim i as integer, n as integer

    i = listGetFirst( itemlist, lTB() )
    do until( i = -1 )
        n = listGetNext( itemlist, lTB() )

        if( itemTB(i).stat = 0 ) then
            listDel itemlist, lTB(), itemTB(i).ln
            itemTB(i).ln = -1
        end if

        i = n
    loop

end sub
Reply
#29
Hey v1ctor!!!! When the ^&^(*&^( are you gonna release Cs2d?!!! Big Grin

Hey, you could write a tute for that in QB express. :*) Of course, if you get your butt of those Java progs yer making. :*)
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#30
Quote:Hey v1ctor!!!! When the ^&^(*&^( are you gonna release Cs2d?!!! :D


Well, since the last month i'm working on another project that will probably take more 1-2 months to get released, so i didn't have time to add anything new to CS2D (like bot states, a config file, net code and so on..). Anyway, if the other project get really done, CS2D will have to be ported (if you know what i mean ;), so any work on the current code isn't worth..


Quote:Hey, you could write a tute for that in QB express. :*) Of course, if you get your butt of those Java progs yer making. :*)

Not only coz my english sucks, but well, i really don't have any free time atm, sorry :/.. i've hash tables, binary trees and DAG's (Graphs) done the same way in pure qb, but modules aren't really generic, they would need a bunch of changes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)