Guest Mixture63 Posted December 31, 2005 Share Posted December 31, 2005 (edited) Requires Mx63.dll plugin - The link is in my sig. This very simple include script lets you create chains of links. Links are good because you can attach them and then easily remove one link and place it somewhere else. Links can contain values. If you know how to use my plugin you will be able to store strings in these chains. Each chain has 4 flags which can have values from 0 to 255. It is zero-indexed. There are instances in which chains may be useful. With creativity you can create more complicated structures that include child and parent links. Now the chains only support back and next and value. But with the flags and value you can make it more complicated. You can make more complicated data structures for all different kinds of things. You can store strings in links by using StringStore() from the plugin to allocate space for a string and gets its address and put that value in the link. Then on chain destruction you can use StringFree() to do the oppisite.Chain.au3 Edited December 31, 2005 by Mixture63 Link to comment Share on other sites More sharing options...
nfwu Posted December 31, 2005 Share Posted December 31, 2005 Nice! now i don't need to represent data structures in arrays and use time consuming functions to modify them! TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
nfwu Posted December 31, 2005 Share Posted December 31, 2005 (edited) A tree data structure: expandcollapse popupfunc TreeElementCreate() $ea = BufferAllocate(24) BufferWriteInt($ea, 0) BufferWriteInt($ea+4, 0) BufferWriteInt($ea+8, 0) BufferWriteInt($ea+12, 0) BufferWriteInt($ea+16, 0) BufferWriteInt($ea+20, 0) return $ea EndFunc func TreeElementDelete($Address) BufferFree($Address, 24) EndFunc func TreeElementAttachLeft($Element, $NextElement) TreeElementSetLeft($Element, $NextElement) TreeElementSetParent($NextElement, $Element) EndFunc func TreeElementDettachLeft($Element) TreeElementSetParent(TreeElementGetLeft($Element), 0) TreeElementSetLeft($Element, 0) EndFunc func TreeElementAttachRight($Element, $NextElement) TreeElementSetRight($Element, $NextElement) TreeElementSetParent($NextElement, $Element) EndFunc func TreeElementDettachRight($Element) TreeElementSetParent(TreeElementGetRight($Element), 0) TreeElementSetRight($Element, 0) EndFunc func TreeElementGetValue($Address) return BufferReadInt($Address) EndFunc func TreeElementSetValue($Address, $Value) BufferWriteInt($Address, $Value) EndFunc func TreeElementGetRight($Address) return BufferReadInt($Address+4) EndFunc func TreeElementSetRight($Address, $Value) BufferWriteInt($Address+4, $Value) EndFunc func TreeElementGetLeft($Address) return BufferReadInt($Address+8) EndFunc func TreeElementSetLeft($Address, $Value) BufferWriteInt($Address+8, $Value) EndFunc func TreeElementGetParent($Address) return BufferReadInt($Address+12) EndFunc func TreeElementSetParent($Address, $Value) BufferWriteInt($Address+12, $Value) EndFunc func TreeElementSetParam1($Address, $Flag) BufferWriteInt($Address+16, $Flag) EndFunc func TreeElementGetParam1($Address) return BufferReadInt($Address+16) EndFunc func TreeElementSetParam2($Address, $Flag) BufferWriteInt($Address+20, $Flag) EndFunc func TreeElementGetParam2($Address) return BufferReadInt($Address+20) EndFunc Edited December 31, 2005 by nfwu TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Guest Mixture63 Posted December 31, 2005 Share Posted December 31, 2005 There is just one error in your code. Your allocating 24 bytes (correct) but you freeing 28 bytes (incorrect). The amount you free should be = to the amount you allocate. Link to comment Share on other sites More sharing options...
nfwu Posted December 31, 2005 Share Posted December 31, 2005 Oops, thanks for pointing it out... TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Guest Mixture63 Posted December 31, 2005 Share Posted December 31, 2005 Oops, thanks for pointing it out...Your welecome.I wonder what other cool structures could be created. Link to comment Share on other sites More sharing options...
nfwu Posted December 31, 2005 Share Posted December 31, 2005 You have linked lists(like your chain), queues, stacks, trees, vectors, lists, deque, etc... TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
Guest Mixture63 Posted December 31, 2005 Share Posted December 31, 2005 (edited) You have linked lists(like your chain), queues, stacks, trees, vectors, lists, deque, etc...You could probably make UDFs for quees and stacks super mega ultra real easy. Edited December 31, 2005 by Mixture63 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now