[MUD-Dev] caved in: Algorithms for for storing free space.
Ben Greear
greear at cyberhighway.net
Sun Apr 5 19:22:14 CEST 1998
On Sun, 5 Apr 1998, Chris Gray wrote:
> [Ben Greear:]
>
> :A binary search wouldn't be too bad, just wondering if there's
> :a better (constant) method??
>
> Isn't there one of those bit-twiddle methods that does that? Or can you
> only find the lowest one bit or something? Not sure where to look for
> the stuff, however. Anyone?
I thought of this..might be ok:
int pwr = 0;
int size; //this is what we want to find
int i = 0;
while ((size >> i) > 0) {
pwr++;
i++;
}
pwr should be the base of two you'll need.
This is a messy example..and might not even work...just a working
idea.....
Ben
Ben Greear (greear at cyberhighway.net) http://www.primenet.com/~greear
Author of ScryMUD: mud.primenet.com 4444
http://www.primenet.com/~greear/ScryMUD/scry.html
More information about the mud-dev-archive
mailing list