Algorithm Help

From: David Mott (dmott_at_austin.rr.not.home.com)
Date: 01/23/04


Date: Fri, 23 Jan 2004 02:43:53 +0000 (UTC)

Hi all, hope someone can help me with an algorithm.

I have a bitmap representing available pages in a file. A
GetPage(PageCount) function should return the offset into the file where
PageCount of contiguous pages resides. Within the function I have a pointer
to the bitmap and want to scan the bitmap until PageCount of free bits is
found. For example assume the following bitmap is present in memory:

10101100110001101010000111111011001011001

If I wanted to retrieve the offset where 4 bits are free, the
FindFreeBitsInBitmap(4) function should return 18 (the location of 0000)

My FindFreeBitsInBitmap(BitCount) function should scan the block of memory
until it encounters BitCount of free bits. Then should return the offset
into the block where the free bits occur. There's several approaches to
this problem, can someone provide me with a very efficient algorithm to
locate the starting offset? This function resides in a DBMS and should be
very efficient as it's called very frequently. All input is greatly
appreciated.

Cheers,
David



Relevant Pages

  • Algorithm Help
    ... I have a bitmap representing available pages in a file. ... PageCount of contiguous pages resides. ... If I wanted to retrieve the offset where 4 bits are free, ...
    (alt.lang.asm)
  • Bit testing
    ... I have a bitmap representing available pages in a file. ... PageCount of contiguous pages resides. ... If I wanted to retrieve the offset where 4 bits are free, ...
    (comp.lang.cpp)
  • Re: Image Tiling with GDI+ and C++
    ... You need to be careful with differentiating offset and stride. ... I'm suspicious of your offset calculations using width*3. ... // code to copy one tile to a destination bitmap... ... problem with the new image (Bitmap object) I create using GDI+. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Image Tiling with GDI+ and C++
    ... I'm suspicious of your offset calculations using width*3. ... width*3 should only be used as the number of bytes per row to copy from the source tile bitmaps to the destination bitmap. ... When moving to the next destination row, the destination bitmap's stride should be used. ...
    (microsoft.public.win32.programmer.gdi)
  • Re: How to display a DIB or draw it into a Bitmap
    ... The correct calculation of the offset for .bfOffBits is important. ... CreateDIBSection would fail! ... If you loaded a bitmap that was aligned this way and did not check the ...
    (microsoft.public.dotnet.languages.vb)