public MatrixDto getContent(Callable<List<Content>> function) {
...
final List<Content> list = function.call();
...
}
// а вызывать так:
getContent(new Callable<List<Content>>() {
public List<Content> call() { return contentDao.x(a, b); }
});
static int binarySearch(int[] A, int n) { int left = 0; int right = A.length; if (right == 0 || n > A[right - 1]) { return right; } while (left < right - 1) { int mid = (left + right) / 2; if (A[mid] <= n) { left = mid; } else { right = mid; } } return A[left] >= n ? left : right; } int leftIndex = binarySearch(A, left); int rightIndex = binarySearch(A, right + 1); int countBetweenLeftAndRight = rightIndex - leftIndex;