ArrayList.LastIndexOf メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
ArrayList 全体またはその一部において、最後に値が出現した位置のインデックス番号 (0 から始まる) を返します。
オーバーロード
LastIndexOf(Object) |
指定した Object を検索し、ArrayList 全体で最後に見つかった位置の 0 から始まるインデックスを返します。 |
LastIndexOf(Object, Int32) |
指定した Object を検索し、最初の要素から、指定したインデックスまでの ArrayList 内の要素の範囲内で最後に出現する位置の 0 から始まるインデックス番号を返します。 |
LastIndexOf(Object, Int32, Int32) |
指定した Object を検索し、指定した数の要素を含み、かつ指定したインデックスで終了する ArrayList 内の要素の範囲内で最後に出現する位置の 0 から始まるインデックス番号を返します。 |
LastIndexOf(Object)
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
public:
virtual int LastIndexOf(System::Object ^ value);
public virtual int LastIndexOf (object value);
public virtual int LastIndexOf (object? value);
abstract member LastIndexOf : obj -> int
override this.LastIndexOf : obj -> int
Public Overridable Function LastIndexOf (value As Object) As Integer
パラメーター
戻り値
value
が見つかった場合は、ArrayList 全体で最後に見つかった位置のインデックス番号 (0 から始まる)。それ以外の場合は -1。
例
次のコード例は、指定した要素が最後に出現するインデックスを決定する方法を示しています。
using namespace System;
using namespace System::Collections;
void PrintIndexAndValues( IEnumerable^ myList );
int main()
{
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList^ myAL = gcnew ArrayList;
myAL->Add( "the" );
myAL->Add( "quick" );
myAL->Add( "brown" );
myAL->Add( "fox" );
myAL->Add( "jumps" );
myAL->Add( "over" );
myAL->Add( "the" );
myAL->Add( "lazy" );
myAL->Add( "dog" );
myAL->Add( "in" );
myAL->Add( "the" );
myAL->Add( "barn" );
// Displays the values of the ArrayList.
Console::WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
String^ myString = "the";
int myIndex = myAL->LastIndexOf( myString );
Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL->LastIndexOf( myString, 8 );
Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL->LastIndexOf( myString, 10, 6 );
Console::WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
void PrintIndexAndValues( IEnumerable^ myList )
{
int i = 0;
IEnumerator^ myEnum = myList->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( " [{0}]: {1}", i++, obj );
}
Console::WriteLine();
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
using System;
using System.Collections;
public class SamplesArrayList {
public static void Main() {
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList myAL = new ArrayList();
myAL.Add( "the" );
myAL.Add( "quick" );
myAL.Add( "brown" );
myAL.Add( "fox" );
myAL.Add( "jumps" );
myAL.Add( "over" );
myAL.Add( "the" );
myAL.Add( "lazy" );
myAL.Add( "dog" );
myAL.Add( "in" );
myAL.Add( "the" );
myAL.Add( "barn" );
// Displays the values of the ArrayList.
Console.WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
string myString = "the";
int myIndex = myAL.LastIndexOf( myString );
Console.WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf( myString, 8 );
Console.WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf( myString, 10, 6 );
Console.WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
public static void PrintIndexAndValues( IEnumerable myList ) {
int i = 0;
foreach ( Object obj in myList )
Console.WriteLine( " [{0}]: {1}", i++, obj );
Console.WriteLine();
}
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
Imports System.Collections
Public Class SamplesArrayList
Public Shared Sub Main()
' Creates and initializes a new ArrayList with three elements of the same value.
Dim myAL As New ArrayList()
myAL.Add("the")
myAL.Add("quick")
myAL.Add("brown")
myAL.Add("fox")
myAL.Add("jumps")
myAL.Add("over")
myAL.Add("the")
myAL.Add("lazy")
myAL.Add("dog")
myAL.Add("in")
myAL.Add("the")
myAL.Add("barn")
' Displays the values of the ArrayList.
Console.WriteLine("The ArrayList contains the following values:")
PrintIndexAndValues(myAL)
' Searches for the last occurrence of the duplicated value.
Dim myString As [String] = "the"
Dim myIndex As Integer = myAL.LastIndexOf(myString)
Console.WriteLine("The last occurrence of ""{0}"" is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf(myString, 8)
Console.WriteLine("The last occurrence of ""{0}"" between the start and index 8 is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf(myString, 10, 6)
Console.WriteLine("The last occurrence of ""{0}"" between index 10 and index 5 is at index {1}.", myString, myIndex)
End Sub
Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
Dim i as Integer
Dim obj As [Object]
For Each obj In myList
Console.WriteLine(" [{0}]: {1}", i, obj)
i = i + 1
Next obj
Console.WriteLine()
End Sub
End Class
' This code produces the following output.
'
' The ArrayList contains the following values:
' [0]: the
' [1]: quick
' [2]: brown
' [3]: fox
' [4]: jumps
' [5]: over
' [6]: the
' [7]: lazy
' [8]: dog
' [9]: in
' [10]: the
' [11]: barn
'
' The last occurrence of "the" is at index 10.
' The last occurrence of "the" between the start and index 8 is at index 6.
' The last occurrence of "the" between index 10 and index 5 is at index 10.
注釈
ArrayListは、最後の要素から始まり、最初の要素で終わる後方に検索されます。
このメソッドは線形検索を実行します。したがって、このメソッドは 操作です O(n)
。ここで n
、 は Countです。
.NET Framework 2.0 以降では、このメソッドは コレクションの オブジェクトEqualsと CompareTo メソッドをitem
使用して、項目が存在するかどうかを判断します。 以前のバージョンの.NET Frameworkでは、この決定は、コレクション内のオブジェクトの パラメーターの item
メソッドと CompareTo メソッドを使用Equalsして行われました。
こちらもご覧ください
適用対象
LastIndexOf(Object, Int32)
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
public:
virtual int LastIndexOf(System::Object ^ value, int startIndex);
public virtual int LastIndexOf (object value, int startIndex);
public virtual int LastIndexOf (object? value, int startIndex);
abstract member LastIndexOf : obj * int -> int
override this.LastIndexOf : obj * int -> int
Public Overridable Function LastIndexOf (value As Object, startIndex As Integer) As Integer
パラメーター
- startIndex
- Int32
後方検索の開始位置を示す 0 から始まるインデックス。
戻り値
最初の要素から startIndex
までの ArrayList 内の要素の範囲内で value
が見つかった場合は、最後に見つかった位置の 0 から始まるインデックス番号。それ以外の場合は -1。
例外
startIndex
は ArrayListの有効なインデックスの範囲外です。
例
次のコード例は、指定した要素が最後に出現するインデックスを決定する方法を示しています。
using namespace System;
using namespace System::Collections;
void PrintIndexAndValues( IEnumerable^ myList );
int main()
{
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList^ myAL = gcnew ArrayList;
myAL->Add( "the" );
myAL->Add( "quick" );
myAL->Add( "brown" );
myAL->Add( "fox" );
myAL->Add( "jumps" );
myAL->Add( "over" );
myAL->Add( "the" );
myAL->Add( "lazy" );
myAL->Add( "dog" );
myAL->Add( "in" );
myAL->Add( "the" );
myAL->Add( "barn" );
// Displays the values of the ArrayList.
Console::WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
String^ myString = "the";
int myIndex = myAL->LastIndexOf( myString );
Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL->LastIndexOf( myString, 8 );
Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL->LastIndexOf( myString, 10, 6 );
Console::WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
void PrintIndexAndValues( IEnumerable^ myList )
{
int i = 0;
IEnumerator^ myEnum = myList->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( " [{0}]: {1}", i++, obj );
}
Console::WriteLine();
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
using System;
using System.Collections;
public class SamplesArrayList {
public static void Main() {
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList myAL = new ArrayList();
myAL.Add( "the" );
myAL.Add( "quick" );
myAL.Add( "brown" );
myAL.Add( "fox" );
myAL.Add( "jumps" );
myAL.Add( "over" );
myAL.Add( "the" );
myAL.Add( "lazy" );
myAL.Add( "dog" );
myAL.Add( "in" );
myAL.Add( "the" );
myAL.Add( "barn" );
// Displays the values of the ArrayList.
Console.WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
string myString = "the";
int myIndex = myAL.LastIndexOf( myString );
Console.WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf( myString, 8 );
Console.WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf( myString, 10, 6 );
Console.WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
public static void PrintIndexAndValues( IEnumerable myList ) {
int i = 0;
foreach ( Object obj in myList )
Console.WriteLine( " [{0}]: {1}", i++, obj );
Console.WriteLine();
}
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
Imports System.Collections
Public Class SamplesArrayList
Public Shared Sub Main()
' Creates and initializes a new ArrayList with three elements of the same value.
Dim myAL As New ArrayList()
myAL.Add("the")
myAL.Add("quick")
myAL.Add("brown")
myAL.Add("fox")
myAL.Add("jumps")
myAL.Add("over")
myAL.Add("the")
myAL.Add("lazy")
myAL.Add("dog")
myAL.Add("in")
myAL.Add("the")
myAL.Add("barn")
' Displays the values of the ArrayList.
Console.WriteLine("The ArrayList contains the following values:")
PrintIndexAndValues(myAL)
' Searches for the last occurrence of the duplicated value.
Dim myString As [String] = "the"
Dim myIndex As Integer = myAL.LastIndexOf(myString)
Console.WriteLine("The last occurrence of ""{0}"" is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf(myString, 8)
Console.WriteLine("The last occurrence of ""{0}"" between the start and index 8 is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf(myString, 10, 6)
Console.WriteLine("The last occurrence of ""{0}"" between index 10 and index 5 is at index {1}.", myString, myIndex)
End Sub
Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
Dim i as Integer
Dim obj As [Object]
For Each obj In myList
Console.WriteLine(" [{0}]: {1}", i, obj)
i = i + 1
Next obj
Console.WriteLine()
End Sub
End Class
' This code produces the following output.
'
' The ArrayList contains the following values:
' [0]: the
' [1]: quick
' [2]: brown
' [3]: fox
' [4]: jumps
' [5]: over
' [6]: the
' [7]: lazy
' [8]: dog
' [9]: in
' [10]: the
' [11]: barn
'
' The last occurrence of "the" is at index 10.
' The last occurrence of "the" between the start and index 8 is at index 6.
' The last occurrence of "the" between index 10 and index 5 is at index 10.
注釈
は ArrayList 、最初の要素から startIndex
始まり、最初の要素で終わる後方に検索されます。
このメソッドは線形検索を実行します。したがって、このメソッドは 操作ですO(n)
。ここでn
、 は の先頭から までのstartIndex
要素のArrayList数です。
このメソッドは、 を呼び出 Object.Equalsすことによって等価性を判断します。
.NET Framework 2.0 以降では、このメソッドは コレクションの オブジェクトEqualsと CompareTo メソッドをitem
使用して、項目が存在するかどうかを判断します。 以前のバージョンの.NET Frameworkでは、この決定は、コレクション内のオブジェクトの パラメーターの item
メソッドと CompareTo メソッドを使用Equalsして行われました。
こちらもご覧ください
適用対象
LastIndexOf(Object, Int32, Int32)
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
- ソース:
- ArrayList.cs
public:
virtual int LastIndexOf(System::Object ^ value, int startIndex, int count);
public virtual int LastIndexOf (object value, int startIndex, int count);
public virtual int LastIndexOf (object? value, int startIndex, int count);
abstract member LastIndexOf : obj * int * int -> int
override this.LastIndexOf : obj * int * int -> int
Public Overridable Function LastIndexOf (value As Object, startIndex As Integer, count As Integer) As Integer
パラメーター
- startIndex
- Int32
後方検索の開始位置を示す 0 から始まるインデックス。
- count
- Int32
検索対象の範囲内にある要素の数。
戻り値
count
個の要素を格納し、startIndex
の位置で終了する ArrayList 内の要素の範囲内で value
が見つかった場合は、最後に見つかった位置の 0 から始まるインデックス番号。それ以外の場合は -1。
例外
startIndex
は ArrayListの有効なインデックスの範囲外です。
- または -
count
が 0 未満です。
- または -
startIndex
および count
が ArrayList 内の正しいセクションを指定していません。
例
次のコード例は、指定した要素が最後に出現するインデックスを決定する方法を示しています。 これは後方検索であるため LastIndexOf
、 count
は + 1 以下 startIndex
である必要があることに注意してください。
using namespace System;
using namespace System::Collections;
void PrintIndexAndValues( IEnumerable^ myList );
int main()
{
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList^ myAL = gcnew ArrayList;
myAL->Add( "the" );
myAL->Add( "quick" );
myAL->Add( "brown" );
myAL->Add( "fox" );
myAL->Add( "jumps" );
myAL->Add( "over" );
myAL->Add( "the" );
myAL->Add( "lazy" );
myAL->Add( "dog" );
myAL->Add( "in" );
myAL->Add( "the" );
myAL->Add( "barn" );
// Displays the values of the ArrayList.
Console::WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
String^ myString = "the";
int myIndex = myAL->LastIndexOf( myString );
Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL->LastIndexOf( myString, 8 );
Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL->LastIndexOf( myString, 10, 6 );
Console::WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
void PrintIndexAndValues( IEnumerable^ myList )
{
int i = 0;
IEnumerator^ myEnum = myList->GetEnumerator();
while ( myEnum->MoveNext() )
{
Object^ obj = safe_cast<Object^>(myEnum->Current);
Console::WriteLine( " [{0}]: {1}", i++, obj );
}
Console::WriteLine();
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
using System;
using System.Collections;
public class SamplesArrayList {
public static void Main() {
// Creates and initializes a new ArrayList with three elements of the same value.
ArrayList myAL = new ArrayList();
myAL.Add( "the" );
myAL.Add( "quick" );
myAL.Add( "brown" );
myAL.Add( "fox" );
myAL.Add( "jumps" );
myAL.Add( "over" );
myAL.Add( "the" );
myAL.Add( "lazy" );
myAL.Add( "dog" );
myAL.Add( "in" );
myAL.Add( "the" );
myAL.Add( "barn" );
// Displays the values of the ArrayList.
Console.WriteLine( "The ArrayList contains the following values:" );
PrintIndexAndValues( myAL );
// Searches for the last occurrence of the duplicated value.
string myString = "the";
int myIndex = myAL.LastIndexOf( myString );
Console.WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf( myString, 8 );
Console.WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex );
// Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf( myString, 10, 6 );
Console.WriteLine( "The last occurrence of \"{0}\" between index 10 and index 5 is at index {1}.", myString, myIndex );
}
public static void PrintIndexAndValues( IEnumerable myList ) {
int i = 0;
foreach ( Object obj in myList )
Console.WriteLine( " [{0}]: {1}", i++, obj );
Console.WriteLine();
}
}
/*
This code produces the following output.
The ArrayList contains the following values:
[0]: the
[1]: quick
[2]: brown
[3]: fox
[4]: jumps
[5]: over
[6]: the
[7]: lazy
[8]: dog
[9]: in
[10]: the
[11]: barn
The last occurrence of "the" is at index 10.
The last occurrence of "the" between the start and index 8 is at index 6.
The last occurrence of "the" between index 10 and index 5 is at index 10.
*/
Imports System.Collections
Public Class SamplesArrayList
Public Shared Sub Main()
' Creates and initializes a new ArrayList with three elements of the same value.
Dim myAL As New ArrayList()
myAL.Add("the")
myAL.Add("quick")
myAL.Add("brown")
myAL.Add("fox")
myAL.Add("jumps")
myAL.Add("over")
myAL.Add("the")
myAL.Add("lazy")
myAL.Add("dog")
myAL.Add("in")
myAL.Add("the")
myAL.Add("barn")
' Displays the values of the ArrayList.
Console.WriteLine("The ArrayList contains the following values:")
PrintIndexAndValues(myAL)
' Searches for the last occurrence of the duplicated value.
Dim myString As [String] = "the"
Dim myIndex As Integer = myAL.LastIndexOf(myString)
Console.WriteLine("The last occurrence of ""{0}"" is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in the first section of the ArrayList.
myIndex = myAL.LastIndexOf(myString, 8)
Console.WriteLine("The last occurrence of ""{0}"" between the start and index 8 is at index {1}.", myString, myIndex)
' Searches for the last occurrence of the duplicated value in a section of the ArrayList. Note that the start index is greater than the end index because the search is done backward.
myIndex = myAL.LastIndexOf(myString, 10, 6)
Console.WriteLine("The last occurrence of ""{0}"" between index 10 and index 5 is at index {1}.", myString, myIndex)
End Sub
Public Shared Sub PrintIndexAndValues(myList As IEnumerable)
Dim i as Integer
Dim obj As [Object]
For Each obj In myList
Console.WriteLine(" [{0}]: {1}", i, obj)
i = i + 1
Next obj
Console.WriteLine()
End Sub
End Class
' This code produces the following output.
'
' The ArrayList contains the following values:
' [0]: the
' [1]: quick
' [2]: brown
' [3]: fox
' [4]: jumps
' [5]: over
' [6]: the
' [7]: lazy
' [8]: dog
' [9]: in
' [10]: the
' [11]: barn
'
' The last occurrence of "the" is at index 10.
' The last occurrence of "the" between the start and index 8 is at index 6.
' The last occurrence of "the" between index 10 and index 5 is at index 10.
注釈
ArrayListが 0 より大きい場合count
は、 からstartIndex
始まり、マイナス count
1 でstartIndex
終わる後方に検索されます。
このメソッドは線形検索を実行します。したがって、このメソッドは 操作です O(n)
。ここで n
、 は count
です。
このメソッドは、 を呼び出 Object.Equalsすことによって等価性を判断します。
.NET Framework 2.0 以降では、このメソッドは コレクションの オブジェクトEqualsと CompareTo メソッドをitem
使用して、項目が存在するかどうかを判断します。 以前のバージョンの.NET Frameworkでは、この決定は、コレクション内のオブジェクトの パラメーターの item
メソッドと CompareTo メソッドを使用Equalsして行われました。
こちらもご覧ください
適用対象
.NET