Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds a util for performing bisection search (or binary searches) on ordered sets of arbitrary objects. The objects can be generated as needed based on an ordered index (where it "would" appear in an ordered set of the objects), and as such does not need to be existing instances in memory in order to be searched.
A use case for this is to iteratively find a generated valid binary file of a
certain size, e.g. PDFs, images, etc, anything that can be translated
from an integer to an object retaining the same notion of "order" as the
integer it is based on.
Generating PDFs with random content using PDFBox:
Each attempted (suggested)
PDDocument
will also be properly closed, being anAutoCloseable
, except from the resultingPDDocument
which is returned from the search. By default, the search will perform at most 20 attempts before returning its last attempt (unless found before).Similarly, this utility could be used to translate points (a.k.a. the integer from the range) to X and Y pixel amount, given a fixed aspect ratio, and generate images with random content, and search for one with a certain size.