class ListUtil {

	@Pure
	public static <T> int lastIndexOf(List<T> list, Comparator<? super T> comparator, T elt) {
		try {
			assert comparator != null;
			assert list != null;
			if (elt == null) {
				return -1;
			}

			int first = 0;
			int last = list.size() - 1;

			while (last >= first) {
				int c = (first + last) / 2;
				final T indata = list.get(c);
				final int cmp = comparator.compare(elt, indata);
				if (cmp == 0) {
					do {
						++c;
					}
					while (c < list.size() && comparator.compare(elt, list.get(c)) == 0);
					return c - 1;
				} else if (cmp < 0) {
					last = c - 1;
				} else {
					first = c + 1;
				}
			}
		} catch (AssertionError e) {
			throw e;
		} catch (Throwable exception) {
			//
		}
		return -1;
	}

	private  ListUtil();

}