code: int writePageIndex(byte []buffer,
                       int head,
                       int type,
                       int pid,
                       int nextPid,
                       int entryOffset, 
                       int entryLength)
    {
      int sublen = 1 + 4 * 4;
      
      if (BLOCK_SIZE - 8 < head + sublen) {
        return -1;
      }
      
      buffer[head] = (byte) type;
      head++;
      
      BitsUtil.writeInt(buffer, head, pid);
      head += 4;
      
      BitsUtil.writeInt(buffer, head, nextPid);
      head += 4;
      
      BitsUtil.writeInt(buffer, head, entryOffset);
      head += 4;
      
      BitsUtil.writeInt(buffer, head, entryLength);
      head += 4;
      
      return head;
    }
docs: Writes a page index.