Aracılığıyla paylaş


Collections.IndexOfSubList(IList<Object>, IList<Object>) Method

Definition

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

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

Parameters

source
IList<Object>

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

target
IList<Object>

the list to search for as a subList of source.

Returns

the starting position of the first 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 first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. More formally, returns the lowest 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 scanning 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.indexOfSubList(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