private int findFirstIndex(List<MemoryMatch> matches, Address start, Address end) {

		int startIndex = findIndexAtOrGreater(matches, start);
		if (startIndex > 0) { // see if address before extends into this range.
			MemoryMatch resultBefore = matches.get(startIndex - 1);
			Address beforeAddr = resultBefore.getAddress();
			int length = resultBefore.getLength();
			if (start.hasSameAddressSpace(beforeAddr) && start.subtract(beforeAddr) < length) {
				return startIndex - 1;
			}
		}

		if (startIndex == matches.size()) {
			return -1;
		}

		MemoryMatch result = matches.get(startIndex);
		Address addr = result.getAddress();
		if (end.compareTo(addr) >= 0) {
			return startIndex;
		}
		return -1;
	}
Listing highlight provider to highlight memory search results.
Ghidra/Features/Base/src/main/java/ghidra/features/base/memsearch/gui/MemoryMatchHighlighter.java