int allocate(BitField exclude,int first){
  if (full) {
    return -1;
  }
  int start=Math.max(0,first - getPos());
  while (true) {
    int free=used.nextClearBit(start);
    if (free >= pageCount) {
      if (start == 0) {
        full=true;
      }
      return -1;
    }
    if (exclude != null && exclude.get(free + getPos())) {
      start=exclude.nextClearBit(free + getPos()) - getPos();
      if (start >= pageCount) {
        return -1;
      }
    }
 else {
      used.set(free);
      store.logUndo(this,data);
      store.update(this);
      return free + getPos();
    }
  }
}

int allocate ( BitField exclude , int first ) { if ( full ) { return - 1 ; } int start = Math . max ( 0 , first - getPos ( ) ) ; while ( true ) { int free = used . nextClearBit ( start ) ; if ( free >= pageCount ) { if ( start == 0 ) { full = true ; } return - 1 ; } if ( exclude != null && exclude . get ( free + getPos ( ) ) ) { start = exclude . nextClearBit ( free + getPos ( ) ) - getPos ( ) ; if ( start >= pageCount ) { return - 1 ; } } else { used . set ( free ) ; store . logUndo ( this , data ) ; store . update ( this ) ; return free + getPos ( ) ; } } }
allocate a page from the free list .
