Advertisement
jargon

Vapor

Jun 16th, 2013
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. 'Timothy2.bas
  2. 'Advanced "Vapor" associative array FreeBASIC source code 0x001
  3. '
  4. 'Created December 22nd 2009 - May 6th 2010 by T.R.Keal
  5. 'Modified June 15th 2013 by T.R.Keal
  6. 'Released under the Gnu Public License 2.0
  7. '
  8. 'Please review the Gnu Public License, Thank you.
  9. 'The GPL can be located online at http://www.gnu.org/copyleft/gpl.html
  10.  
  11.  
  12. const Vapor_IS_WRITTEN=1
  13. type Vapor_Node_Type
  14. written as unsigned long
  15. address as unsigned long
  16. end type
  17. type Vapor_Cell_Type
  18. leaf as Vapor_Node_Type
  19. parent as Vapor_Node_Type
  20. prior as Vapor_Node_Type
  21. latter as Vapor_Node_Type
  22. child(0 to 255) as Vapor_Node_Type
  23. length as unsigned long
  24. value as string
  25. end type
  26.  
  27. sub Vapor_MkLeaf(byref tree() as Vapor_Cell, byval address as unsigned long, byref label as string, byref value as string, byval label_offset as unsigned integer)
  28. dim as byte temp=0
  29. if len(label)=0 then
  30. if (tree(address).leaf.written and Vapor_IS_WRITTEN)=Vapor_IS_WRITTEN then
  31. tree(address).value=value
  32. tree(address).length=len(value)
  33. elseif (((tree(address).leaf.written) xor Vapor_IS_WRITTEN) and Vapor_IS_WRITTEN)=Vapor_IS_WRITTEN then
  34. tree(address).leaf.written))=tree(address).leaf.written)) or Vapor_IS_WRITTEN
  35. tree(address).value=value
  36. tree(address).length=len(value)
  37. endif
  38. else
  39. temp=asc(left(label,label_offset+1))
  40. if (tree(address).child(temp).written and Vapor_IS_WRITTEN)=Vapor_IS_WRITTEN then
  41. Vapor_MkLeaf tree(), address, label, value, label_offset+1
  42. elseif (((tree(address).child(temp).written) xor Vapor_IS_WRITTEN) and Vapor_IS_WRITTEN)=Vapor_IS_WRITTEN then
  43. tree(address).child(temp).written=tree(address).child(temp).written or Vapor_IS_WRITTEN
  44. tree(address).child(temp).address=tree(address).child(temp).address=tree(0).leaf.address+1
  45. tree(address).child(temp).parent.written=(tree(address).child(temp).parent.written or Vapor_IS_WRITTEN)
  46. redim preserve tree(0 to tree(0).leaf.address+1)
  47. tree(address).child(temp).parent=address
  48. endif
  49. endif
  50. end sub
  51.  
  52. redim as Vapor_Cell Tree()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement