def insert(id)
      # Find the index of the page that should hold ID.
      index = @page_records.bsearch_index { |pr| pr.max_id >= id }
      # Get the corresponding IDListPageRecord object.
      page = @page_records[index]

      # In case the page is already full we'll have to create a new page.
      # There is no guarantee that a split will yield an page with space as we
      # split by ID range, not by distributing the values evenly across the
      # two pages.
      while page.is_full?
        new_page = page.split
        # Store the newly created page into the page_records list.
        @page_records.insert(index + 1, new_page)
        if id >= new_page.min_id
          # We need to insert the ID into the newly created page. Adjust index
          # and page reference accordingly.
          index += 1
          page = new_page
        end
      end

      # Insert the ID into the page.
      page.insert(id)
    end
def insert(id)
      # Find the index of the page that should hold ID.
      index = @page_records.bsearch_index { |pr| pr.max_id >= id }
      # Get the corresponding IDListPageRecord object.
      page = @page_records[index]

      # In case the page is already full we'll have to create a new page.
      # There is no guarantee that a split will yield an page with space as we
      # split by ID range, not by distributing the values evenly across the
      # two pages.
      while page.is_full?
        new_page = page.split
        # Store the newly created page into the page_records list.
        @page_records.insert(index + 1, new_page)
        if id >= new_page.min_id
          # We need to insert the ID into the newly created page. Adjust index
          # and page reference accordingly.
          index += 1
          page = new_page
        end
      end

      # Insert the ID into the page.
      page.insert(id)
    end
Create a new IDList object. The data that can't be kept in memory will
 be stored in the specified directory under the given name.
 @param dir [String] Path of the directory
 @param name [String] Name of the file
 @param max_in_memory [Integer] Specifies the maximum number of values
        that will be kept in memory. If the list is larger, values will
        be cached in the specified file.
 @param page_size [Integer] The number of values per page. The default
        value is 32 which was found the best performing config in  tests.
 Insert a new value into the list.
 @param id [Integer] The value to add