Bank module
BlitzMax Forums/BlitzMax Module Tweaks/Bank module
| ||
Ok, I made the bank module help much more informative(IMHO), as well as 2 extra methods/functions. I also implemented an intelligent autoresize system that is by default off and can be turned on. (described in help for resizebank). And an example using new features: Mine:TBank=CreateBank(0) Mine.AutoResizeLimit=50 Mine.ResizeIncrement=10 Mine.PokeBit(0,0,1) Mine.PokeBit(0,1,0) Mine.PokeBit(0,2,1) Mine.PokeBit(0,3,1) Mine.PokeBit(0,4,0) Mine.PokeBit(0,5,0) Mine.PokeBit(0,6,1) Mine.PokeBit(0,7,0) Mine.PokeInt(1,60) For Local j=0 To 4 For Local i=0 Until 8 Print ""+Mine.PeekBit(j,i) Next Next Print Mine.PeekByte(0) Print "Bank is "+Mine.Size()+" bytes long" Print "This is for resizebank speed reasons" BRL, I would suggest simply copy pasting this into your bank.bmx file. |
| ||
As some people will be using banks for performance, the extra if added in poke for auto-resizing seems to be a bad idea. I'd suggest that a more appropriate way of implementing this would be to Extend the TBank type into a TResizeableBank, and over-ride the relevant methods. |
| ||
IMHO, if you want performance you can just do:RawMem:Byte Ptr=MemAlloc(50) RawMem[0]=5 RawMem[1]=2This would be alot faster than the original bank functions as well. Anyway, I've seen many times people us banks as a dynamic data structure and resizing every time data is added. This is veerrry sloooow, something my autoresizing stuff doesnt suffer from due to ResizeIncrement. I guess I can wrie it extending bank class, although, if you are going to worry about the speed of an extra if, maybe I should just copy this class and rename it. An extra if and a comparisent isnt going to affect too much. If your worried about this might as well leave BMAX and grab a copy of Dev-C++ eh? |
| ||
The other reason for extending the type (rather than replacing) is to avoid your changes being lost on a syncmods (unless TBank is Final?) |
| ||
True. I'm hoping BRL will consider and implement some of the features. At least use the new docs. |