Partager via


Collections.LastIndexOfSubList Method

Definition

Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.

[Android.Runtime.Register("lastIndexOfSubList", "(Ljava/util/List;Ljava/util/List;)I", "")]
public static int LastIndexOfSubList (System.Collections.Generic.IList<object> source, System.Collections.Generic.IList<object> target);
[<Android.Runtime.Register("lastIndexOfSubList", "(Ljava/util/List;Ljava/util/List;)I", "")>]
static member LastIndexOfSubList : System.Collections.Generic.IList<obj> * System.Collections.Generic.IList<obj> -> int

Parameters

source
IList<Object>

the list in which to search for the last occurrence of target.

target
IList<Object>

the list to search for as a subList of source.

Returns

the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence.

Attributes

Remarks

Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. More formally, returns the highest index i such that source.subList(i, i+target.size()).equals(target), or -1 if there is no such index. (Returns -1 if target.size() > source.size())

This implementation uses the "brute force" technique of iterating over the source list, looking for a match with the target at each location in turn.

Added in 1.4.

Java documentation for java.util.Collections.lastIndexOfSubList(java.util.List<?>, java.util.List<?>).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to