リスト
「リスト」の意味・「リスト」とは
「リスト」とは、複数の項目や要素を一定の順序や規則に従って並べたものである。リストは、情報を整理・分類する際に用いられることが多く、項目間の関連性や優先順位を明確にすることができる。例えば、買い物リストやタスクリストなどが挙げられる。「リスト」の語源
「リスト」の語源は、英語の ""list"" に由来する。英語の ""list"" は、中英語の ""liste"" や古フランス語の ""liste"" から来ており、さらにそれらはラテン語の ""līsta"" に由来する。これらの言語では、リストは細長い布や紙に書かれた項目の並びを意味していた。「リスト」に関連する用語・知識
「リスト」の英語表現
英語では、""list"" という単語が「リスト」に相当する。また、""to list"" という動詞は、項目をリストに追加することを意味する。さらに、""listing"" はリストに載せることやリスト自体を指すことがある。フランツ・リストとは
フランツ・リストは、19世紀のハンガリー出身のピアニスト・作曲家である。彼は、ピアノの技巧を極めた演奏家として知られるとともに、多くの作品を残した作曲家でもあった。彼の作品は、ロマン派音楽の代表的なものとされている。フランツ・リストの生涯
フランツ・リストは、1811年にハンガリーで生まれ、幼少期から音楽の才能を示した。ウィーンやパリで音楽を学び、その後ヨーロッパ各地で演奏活動を行った。晩年は教育者としても活躍し、多くの後進を育てた。彼は1886年に亡くなった。「リスト」を用いた例文
1. 買い物リストに書かれた食材を全てスーパーで購入した。 2. 今日のタスクリストには、会議への出席や資料作成が含まれている。 3. 不動産会社から提供されたリストをもとに、物件を比較検討している。list
「list」の意味
【名詞】一覧表、リスト、名簿、目録、価格表、明細書、傾き、畝、織物の縁例英文:A list of players
和訳:選手名簿
【他動詞】〜を表にする、〜を列挙する、〜を一覧表にする、〜を一覧表に載せる、傾ける、〜を好む、〜を望む
例英文:Please list your name.
和訳:あなたの名前を名簿に記載してください。
【自動詞】記載してある、傾く、欲する
例英文:The ship begin to list.
和訳:その船は、傾き始めた。
「list」発音・読み方
発音:[list]読み方(カタカナ表記):リスト
「list」の複数形
lists「list」に関連する用語の解説
「list(python)」とは
Python(パイソン)は、プログラミング言語の一種である。Pythonにおいて「list」は、リスト(配列)を作るために使われるデータ型の一種を表す用語である。リストは、任意の複数の要素を格納することができるコンテナ型(コレクション型)のデータである。「任意の複数の要素」とは、整数(int型)、不動小数点(float型)、文字列(str型)などのことであり、Pythonのlistでは、これらの複数のデータ型を格納することができる。格納された各要素には、格納した順(左から順)に番号が付けられる。これはプログラミングの慣習であるが、番号は0から始まるので、一番左の要素が0番目としてカウントされる。コンテナに格納したデータはインデックスを用いて指定することが可能で、必要に応じて検索したり、追加したり、削除したり、カウントしたりすることができる。
Pythonにおけるlistのプログラム(コード)は、例えば以下のように使用する。
・リストを作成する
任意の配列名 = [要素A, 要素B, 要素C, 要素D]
例:alphabet = [a, b, c]
・リストに要素を追加する
任意の配列名.append(追加したい要素)
例:alphabet = [a, b, c]
alphabet.append(d)
print(alphabet)→[a,b,c,d]
・リストの要素を削除する
任意の配列名.remove(削除したい要素)
例:alphabet = [a, b, c]
alphabet.remove(b)
print(alphabet)→[a,c]
・リストを初期化する
任意の配列名.clear()
例:alphabet.clear()
「To Do List」とは
「やるべきこと(To Do)の一覧表(List)」という意味である。ToDoリストを作成することで、タスクを管理しやすくなるというメリットがある。やるべきタスクを可視化することで、タスクを忘れることを防いだり、タスクに優先順位をつけたり、タスクを整理して作業の効率化を図ったりすることをねらいとしている。ToDoリストを作る方法としては、付箋やメモ帳などを用いたアナログな方法と、ToDoリストを管理するアプリケーションを用いたデジタルな方法がある。デジタルな方法においては、ToDoリストを管理するための様々なアプリケーションが開発されており、リマインダー機能、お知らせ機能、チェックリスト機能、共有機能、時間管理機能など、多種多様な機能を有したものがある。
ToDoリストは、個人の作業効率を上げる他に、チームの生産性を高めるために使われる場合もある。また、業務上の用途の他に、人生の幸福度を上げる用途として使用される場合もある。この場合、リストには「やるべきこと」の他にも「やりたいこと」、「行きたい場所」、「食べたい物」などを列挙し、人生の中長期的なプランの指標とすることがある。
「a-list」とは
A級の人を指す形容詞、あるいはA級の人のリストを表す言葉である。A級の人とは、「最高クラス」、「大物」、「有名」、「一流」などと称される人のことである。また、A級の人のことをA-listerと呼ぶ。誰もが知っているレベルであるA級の人に対して、まあまあ認知度のあるB級の人を指す「B-list」という表現も存在する。
例英文:A-list of baseball world
和訳:野球界の大物
「on the list」とは
「リストに載っている」という意味を表す英熟語である。「on the list」と似た英熟語に「in the list」がある。両者は同じ意味をもっており、前置詞の前にある単語によって「on」と「in」を使い分ける。
例英文:He is an actor on the list.
和訳:彼が、リストに載っている俳優だよ。
リスト
ダイレクトマーケティングになくてはならないもののひとつは顧客リスト。顧客に関する情報を集めたもの。趣味や興味(ライフスタイル)のサイコグラフィック・ヒストリー、購買ヒストリー(購入年月日、購入製品やサービス、数量、金額など)、デモグラフィック・プロフィール(性別・年齢・住居・学歴・年収など)、メンバーシップ履歴などを有した個々人の名前と住所のレコードを収集したもの。個々人の個人リスト、学校などの団体に所属している団体リスト、名前の出所によるリストなど、さまざまなタイプのリストが存在する。カタログハウスの顧客を集めた通販リスト、医療専門家を編集してつくられたリスト、雑誌購読者のリスト、高校生リスト、クレジット購入者リストなど特殊リストもある。リストはダイレクト・マーケティング業界の命といわれるほど重要なものである。
list
list — 配列と同様の形式で、複数の変数への代入を行う
説明
void list ( mixed varname, mixed ... )array() と同様に、 この関数は実際には関数ではなく言語の構成要素です。 list() は、 単一の操作で一連の変数に値を代入するために使われます。
注意: list() は数値添字の配列のみを生成します。 添字は 0 から始まります。
例 291. list() の例
<?php
$info = array('coffee', 'brown', 'caffeine');
// Listing all the variables
list($drink, $color, $power) = $info;
echo "$drink is $color and $power makes it special.\n";
// Listing some of them
list($drink, , $power) = $info;
echo "$drink has $power.\n";
// Or let's skip to only the third one
list( , , $power) = $info;
echo "I need $power!\n";
?>
例 292. list() の使用法の例
<table>
<tr>
<th>社員氏名</th>
<th>給与</th>
</tr>
<?php
$result = mysql_query("SELECT id, name, salary FROM employees", $conn);
while (list($id, $name, $salary) = mysql_fetch_row($result)) {
echo " <tr>\n" .
" <td><a href=\"info.php?id=$id\">$name</a></td>\n" .
" <td>$salary</td>\n" .
" </tr>\n";
}
?>
</table>
警告 |
list()は、最も右のパラメータから値を代入します。
プレーンな変数を使用している場合には、このことを気にする必要はありません。
しかし、添字配列を使用している場合には、配列の添字の順番が
list()
に書いたものと同じく左から右となることを通常は期待しますが、
そうはなりません。この配列の添字は逆の順番となります。
|
例 293. 配列の添字を使用した list() の例
<?php
$info = array('coffee', 'brown', 'caffeine');
list($a[0], $a[1], $a[2]) = $info;
var_dump($a);
?>
次のような出力になります(list() の文法に書かれた
順番と、要素の順番の違いに注意):
array(3) { [2]=> string(8) "caffeine" [1]=> string(5) "brown" [0]=> string(6) "coffee" }
each()、array() および extract() も参照ください。
List イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | ItemCommand | List コントロールに関連付けられているコマンドをユーザーが選択すると発生します。 |
![]() | ItemDataBind | List 内の項目がデータにバインドされたときに発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | LoadItems | コントロールの改ページ位置が自動修正され、さらにデータを必要とする場合に発生します。 ( PagedControl から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

List クラス
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)

Public Class List Inherits PagedControl Implements INamingContainer, ITemplateable, IPostBackEventHandler

このコントロールは、デバイス テンプレート セットと内部的な改ページ位置の自動修正の使用により、テンプレート レンダリングをサポートしています。詳細については、ASP.NET デバイスのフィルタ処理の概要、改ページ調整 の各トピックを参照してください。

配列を使用して List オブジェクトをバインドし、項目を格納するコード例を次に示します。List オブジェクトの DataTextField プロパティと DataValueField プロパティはプログラムによって設定できます。
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> ' Persist across multiple postbacks. Private Shared doneCount, schedCount, pendCount As Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Set the DataMembers of the List List1.DataValueField = "Status" List1.DataTextField = "TaskName" ' Create an ArrayList of task data Dim arr As ArrayList = New ArrayList() arr.Add(New Task("Define transactions", "scheduled")) arr.Add(New Task("Verify transactions", "scheduled")) arr.Add(New Task("Check balance sheet", "scheduled")) arr.Add(New Task("Compile balance sheet", "scheduled")) arr.Add(New Task("Prepare report", "scheduled")) arr.Add(New Task("Send report", "scheduled")) ' Bind the array to the list List1.DataSource = arr List1.DataBind() Const spec As String = "Start: {0} tasks are done, {1} " & _ "tasks are scheduled, and {2} tasks are pending." Label2.Text = String.Format(spec, doneCount, _ schedCount, pendCount) List1.Decoration = ListDecoration.Bulleted End If End Sub Private Sub Status_ItemCommand(ByVal sender As Object, _ ByVal e As ListCommandEventArgs) Const spec As String = "You now have {0} tasks done, {1} " & _ "tasks scheduled, and {2} tasks pending." ' Move selection to next status toward 'done' Select Case e.ListItem.Value Case "scheduled" schedCount -= 1 pendCount += 1 e.ListItem.Value = "pending" Case "pending" pendCount -= 1 doneCount += 1 e.ListItem.Value = "done" End Select ' Show the status of the current task Label1.Text = e.ListItem.Text & " is " & _ e.ListItem.Value ' Show current selection counts Label2.Text = String.Format(spec, doneCount, _ schedCount, pendCount) End Sub Private Sub Status_DataBinding(ByVal sender As Object, _ ByVal e As ListDataBindEventArgs) ' Increment initial counts Select Case e.ListItem.Value Case "done" doneCount += 1 Case "scheduled" schedCount += 1 Case "pending" pendCount += 1 End Select End Sub ' Custom class for the ArrayList items Private Class Task Private _TaskName, _Status As String Public Sub New(ByVal TaskName As String, _ ByVal Status As String) _TaskName = TaskName _Status = Status End Sub Public ReadOnly Property TaskName() As String Get Return _TaskName End Get End Property Public ReadOnly Property Status() As String Get Return _Status End Get End Property End Class </script> <html > <body> <mobile:form id="form1" runat="server"> <mobile:Label ID="Label3" Runat="server"> Click a task to change its status from scheduled to pending or from pending to done: </mobile:Label> <mobile:List runat="server" id="List1" OnItemCommand="Status_ItemCommand" OnItemDataBind="Status_DataBinding" /> <mobile:Label runat="server" id="Label1" ForeColor="green" Font-Italic="true" /> <mobile:Label id="Label2" runat="server" /> </mobile:form> </body> </html>
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <script runat="server"> ' Persist across multiple postbacks. Private Shared doneCount, schedCount, pendCount As Integer Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If Not IsPostBack Then ' Set the DataMembers of the List List1.DataValueField = "Status" List1.DataTextField = "TaskName" ' Create an ArrayList of task data Dim arr As ArrayList = New ArrayList() arr.Add(New Task("Define transactions", "scheduled")) arr.Add(New Task("Verify transactions", "scheduled")) arr.Add(New Task("Check balance sheet", "scheduled")) arr.Add(New Task("Compile balance sheet", "scheduled")) arr.Add(New Task("Prepare report", "scheduled")) arr.Add(New Task("Send report", "scheduled")) ' Bind the array to the list List1.DataSource = arr List1.DataBind() Const spec As String = "Start: {0} tasks are done, {1} " & _ "tasks are scheduled, and {2} tasks are pending." Label2.Text = String.Format(spec, doneCount, _ schedCount, pendCount) List1.Decoration = ListDecoration.Bulleted End If End Sub Private Sub Status_DataBinding(ByVal sender As Object, _ ByVal e As ListDataBindEventArgs) ' Increment initial counts Select Case e.ListItem.Value Case "done" doneCount += 1 Case "scheduled" schedCount += 1 Case "pending" pendCount += 1 End Select End Sub Private Sub Status_ItemCommand(ByVal sender As Object, _ ByVal e As ListCommandEventArgs) Const spec As String = "You now have {0} tasks done, {1} " & _ "tasks scheduled, and {2} tasks pending." ' Move selection to next status toward 'done' Select Case e.ListItem.Value Case "scheduled" schedCount -= 1 pendCount += 1 e.ListItem.Value = "pending" Case "pending" pendCount -= 1 doneCount += 1 e.ListItem.Value = "done" End Select ' Show the status of the current task Label1.Text = e.ListItem.Text & " is " & _ e.ListItem.Value ' Show current selection counts Label2.Text = String.Format(spec, doneCount, _ schedCount, pendCount) End Sub ' Custom class for the ArrayList items Private Class Task Private _TaskName, _Status As String Public Sub New(ByVal TaskName As String, _ ByVal Status As String) _TaskName = TaskName _Status = Status End Sub Public ReadOnly Property TaskName() As String Get Return _TaskName End Get End Property Public ReadOnly Property Status() As String Get Return _Status End Get End Property End Class </script> <html > <body> <mobile:form id="form1" runat="server"> <mobile:Label ID="Label3" Runat="server"> Click a task to change its status from scheduled to pending or from pending to done: </mobile:Label> <mobile:List runat="server" id="List1" OnItemCommand="Status_ItemCommand" OnItemDataBind="Status_DataBinding" /> <mobile:Label runat="server" id="Label1" ForeColor="green" Font-Italic="true" /> <mobile:Label id="Label2" runat="server" /> </mobile:form> </body> </html>


System.Web.UI.Control
System.Web.UI.MobileControls.MobileControl
System.Web.UI.MobileControls.PagedControl
System.Web.UI.MobileControls.List


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List コンストラクタ ()
アセンブリ: mscorlib (mscorlib.dll 内)


List の容量は、List が保持できる要素数になります。List に要素を追加すると、必要に応じて、内部の配列の再割り当てによって容量が自動的に増加します。
コレクションのサイズを推定できる場合は、List(Int32) コンストラクタを使用して初期量を指定すると、List に要素を追加するときに、サイズ変更操作を何度も実行する必要がなくなります。
容量を減らすには、TrimExcess メソッドを呼び出すか、Capacity プロパティを明示的に設定します。容量を減らすと、メモリの再割り当てが行われ、List 内のすべての要素がコピーされます。

List ジェネリック クラスの既定のコンストラクタを使用したコード例を次に示します。既定のコンストラクタは、Capacity プロパティの表示で示すような、容量が 0 のリストを作成します。
コード例では、項目の追加、挿入、および削除を行い、これらのメソッドを使用したときに容量がどう変更されるかを示します。
Imports System Imports System.Collections.Generic Public Class Example Public Shared Sub Main() Dim dinosaurs As New List(Of String) Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) dinosaurs.Add("Tyrannosaurus") dinosaurs.Add("Amargasaurus") dinosaurs.Add("Mamenchisaurus") dinosaurs.Add("Deinonychus") dinosaurs.Add("Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) Console.WriteLine(vbLf & "Contains(""Deinonychus""): {0}", _ dinosaurs.Contains("Deinonychus")) Console.WriteLine(vbLf & "Insert(2, ""Compsognathus"")") dinosaurs.Insert(2, "Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "dinosaurs(3): {0}", dinosaurs(3)) Console.WriteLine(vbLf & "Remove(""Compsognathus"")") dinosaurs.Remove("Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next dinosaurs.TrimExcess() Console.WriteLine(vbLf & "TrimExcess()") Console.WriteLine("Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) dinosaurs.Clear() Console.WriteLine(vbLf & "Clear()") Console.WriteLine("Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) End Sub End Class ' This code example produces the following output: ' 'Capacity: 0 ' 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'Capacity: 8 'Count: 5 ' 'Contains("Deinonychus"): True ' 'Insert(2, "Compsognathus") ' 'Tyrannosaurus 'Amargasaurus 'Compsognathus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'dinosaurs(3): Mamenchisaurus ' 'Remove("Compsognathus") ' 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'TrimExcess() 'Capacity: 5 'Count: 5 ' 'Clear() 'Capacity: 5 'Count: 0
using System; using System.Collections.Generic; public class Example { public static void Main() { List<string> dinosaurs = new List<string>(); Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); dinosaurs.Add("Tyrannosaurus"); dinosaurs.Add("Amargasaurus"); dinosaurs.Add("Mamenchisaurus"); dinosaurs.Add("Deinonychus"); dinosaurs.Add("Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); Console.WriteLine("\nContains(\"Deinonychus\"): {0}" , dinosaurs.Contains("Deinonychus")); Console.WriteLine("\nInsert(2, \"Compsognathus\")"); dinosaurs.Insert(2, "Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } Console.WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]); Console.WriteLine("\nRemove(\"Compsognathus\")"); dinosaurs.Remove("Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } dinosaurs.TrimExcess(); Console.WriteLine("\nTrimExcess()"); Console.WriteLine("Capacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); dinosaurs.Clear(); Console.WriteLine("\nClear()"); Console.WriteLine("Capacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); } } /* This code example produces the following output: Capacity: 0 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus Capacity: 8 Count: 5 Contains("Deinonychus"): True Insert(2, "Compsognathus") Tyrannosaurus Amargasaurus Compsognathus Mamenchisaurus Deinonychus Compsognathus dinosaurs[3]: Mamenchisaurus Remove("Compsognathus") Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus TrimExcess() Capacity: 5 Count: 5 Clear() Capacity: 5 Count: 0 */
using namespace System; using namespace System::Collections::Generic; void main() { List<String^>^ dinosaurs = gcnew List<String^>(); Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); dinosaurs->Add("Tyrannosaurus"); dinosaurs->Add("Amargasaurus"); dinosaurs->Add("Mamenchisaurus"); dinosaurs->Add("Deinonychus"); dinosaurs->Add("Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); Console::WriteLine("\nContains(\"Deinonychus\"): {0}", dinosaurs->Contains("Deinonychus")); Console::WriteLine("\nInsert(2, \"Compsognathus\")"); dinosaurs->Insert(2, "Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]); Console::WriteLine("\nRemove(\"Compsognathus\")"); dinosaurs->Remove("Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } dinosaurs->TrimExcess(); Console::WriteLine("\nTrimExcess()"); Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); dinosaurs->Clear(); Console::WriteLine("\nClear()"); Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); } /* This code example produces the following output: Capacity: 0 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus Capacity: 8 Count: 5 Contains("Deinonychus"): True Insert(2, "Compsognathus") Tyrannosaurus Amargasaurus Compsognathus Mamenchisaurus Deinonychus Compsognathus dinosaurs[3]: Mamenchisaurus Remove("Compsognathus") Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus TrimExcess() Capacity: 5 Count: 5 Clear() Capacity: 5 Count: 0 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List コンストラクタ

名前 | 説明 |
---|---|
List () | 空で、既定の初期量を備えた、List クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
List (ジェネリック IEnumerable) | 指定したコレクションからコピーした要素を格納し、コピーされる要素の数を格納できるだけの容量を備えた、List クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |
List (Int32) | 空で、指定した初期量を備えた、List クラスの新しいインスタンスを初期化します。 .NET Compact Framework によってサポートされています。 |

List コンストラクタ (Int32)
アセンブリ: mscorlib (mscorlib.dll 内)



List の容量は、List が保持できる要素数になります。List に要素を追加すると、必要に応じて、内部の配列の再割り当てによって容量が自動的に増加します。
コレクションのサイズを推定できる場合は、初期量を指定すると、List に要素を追加するときに、サイズ変更操作を何度も実行する必要がなくなります。
容量を減らすには、TrimExcess メソッドを呼び出すか、Capacity プロパティを明示的に設定します。容量を減らすと、メモリの再割り当てが行われ、List 内のすべての要素がコピーされます。

List(Int32) コンストラクタのコード例を次に示します。リストの最終的なサイズはちょうど 4 になることがわかっているため、容量が 4 の文字列の List が作成されます。リストに 4 つの文字列が設定され、読み取り専用のコピーが AsReadOnly メソッドを使用して作成されます。
Imports System Imports System.Collections.Generic Public Class Example Public Shared Sub Main() Dim dinosaurs As New List(Of String)(4) Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) dinosaurs.Add("Tyrannosaurus") dinosaurs.Add("Amargasaurus") dinosaurs.Add("Mamenchisaurus") dinosaurs.Add("Deinonychus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & _ "Dim roDinosaurs As IList(Of String) = dinosaurs.AsReadOnly") Dim roDinosaurs As IList(Of String) = dinosaurs.AsReadOnly Console.WriteLine(vbLf & "Elements in the read-only IList:") For Each dinosaur As String In roDinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "dinosaurs(2) = ""Coelophysis""") dinosaurs(2) = "Coelophysis" Console.WriteLine(vbLf & "Elements in the read-only IList:") For Each dinosaur As String In roDinosaurs Console.WriteLine(dinosaur) Next End Sub End Class ' This code example produces the following output: ' 'Capacity: 4 ' 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus ' 'Dim roDinosaurs As IList(Of String) = dinosaurs.AsReadOnly ' 'Elements in the read-only IList: 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus ' 'dinosaurs(2) = "Coelophysis" ' 'Elements in the read-only IList: 'Tyrannosaurus 'Amargasaurus 'Coelophysis 'Deinonychus
using System; using System.Collections.Generic; public class Example { public static void Main() { List<string> dinosaurs = new List<string>(4); Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); dinosaurs.Add("Tyrannosaurus"); dinosaurs.Add("Amargasaurus"); dinosaurs.Add("Mamenchisaurus"); dinosaurs.Add("Deinonychus"); Console.WriteLine(); foreach(string s in dinosaurs) { Console.WriteLine(s); } Console.WriteLine("\nIList<string> roDinosaurs = dinosaurs.AsReadOnly()"); IList<string> roDinosaurs = dinosaurs.AsReadOnly(); Console.WriteLine("\nElements in the read-only IList:"); foreach(string dinosaur in roDinosaurs) { Console.WriteLine(dinosaur); } Console.WriteLine("\ndinosaurs[2] = \"Coelophysis\""); dinosaurs[2] = "Coelophysis"; Console.WriteLine("\nElements in the read-only IList:"); foreach(string dinosaur in roDinosaurs) { Console.WriteLine(dinosaur); } } } /* This code example produces the following output: Capacity: 4 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus IList<string> roDinosaurs = dinosaurs.AsReadOnly() Elements in the read-only IList: Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus dinosaurs[2] = "Coelophysis" Elements in the read-only IList: Tyrannosaurus Amargasaurus Coelophysis Deinonychus */
using namespace System; using namespace System::Collections::Generic; void main() { List<String^>^ dinosaurs = gcnew List<String^>(4); Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); dinosaurs->Add("Tyrannosaurus"); dinosaurs->Add("Amargasaurus"); dinosaurs->Add("Mamenchisaurus"); dinosaurs->Add("Deinonychus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs) { Console::WriteLine(dinosaur); } Console::WriteLine("\nIList<String^>^ roDinosaurs = dinosaurs->AsReadOnly()"); IList<String^>^ roDinosaurs = dinosaurs->AsReadOnly(); Console::WriteLine("\nElements in the read-only IList:"); for each(String^ dinosaur in roDinosaurs) { Console::WriteLine(dinosaur); } Console::WriteLine("\ndinosaurs[2] = \"Coelophysis\""); dinosaurs[2] = "Coelophysis"; Console::WriteLine("\nElements in the read-only IList:"); for each(String^ dinosaur in roDinosaurs) { Console::WriteLine(dinosaur); } } /* This code example produces the following output: Capacity: 4 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus IList<String^>^ roDinosaurs = dinosaurs->AsReadOnly() Elements in the read-only IList: Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus dinosaurs[2] = "Coelophysis" Elements in the read-only IList: Tyrannosaurus Amargasaurus Coelophysis Deinonychus */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List コンストラクタ (ジェネリック IEnumerable)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Sub New ( _ collection As IEnumerable(Of T) _ )
Dim collection As IEnumerable(Of T) Dim instance As New List(Of T)(collection)
public List ( IEnumerable<T> collection )
public: List ( IEnumerable<T>^ collection )
public List ( IEnumerable<T> collection )
public function List ( collection : IEnumerable<T> )

例外の種類 | 条件 |
---|---|
ArgumentNullException | collection が null 参照 (Visual Basic では Nothing) です。 |

List の容量は、List が保持できる要素数になります。List に要素を追加すると、必要に応じて、内部の配列の再割り当てによって容量が自動的に増加します。
コレクションのサイズを推定できる場合は、初期量を指定すると、List に要素を追加するときに、サイズ変更操作を何度も実行する必要がなくなります。
容量を減らすには、TrimExcess メソッドを呼び出すか、Capacity プロパティを明示的に設定します。容量を減らすと、メモリの再割り当てが行われ、List 内のすべての要素がコピーされます。
要素は、コレクションの列挙子によって読み取られる順序と同じ順序で、List にコピーされます。
このコンストラクタは O(n) 操作です (n は collection 内の要素数)。

List コンストラクタと、範囲に対して動作する、List クラスの各種メソッドを使用したコード例を次に示します。文字列の配列が作成され、コンストラクタに渡されます。リストにその配列の要素が追加されます。次に Capacity プロパティが表示され、初期量が、ちょうど入力要素を格納するために必要な容量であることが示されます。
Imports System Imports System.Collections.Generic Public Class Example Public Shared Sub Main() Dim input() As String = { "Brachiosaurus", _ "Amargasaurus", _ "Mamenchisaurus" } Dim dinosaurs As New List(Of String)(input) Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "AddRange(dinosaurs)") dinosaurs.AddRange(dinosaurs) Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "RemoveRange(2, 2)") dinosaurs.RemoveRange(2, 2) Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next input = New String() { "Tyrannosaurus", _ "Deinonychus", _ "Velociraptor" } Console.WriteLine(vbLf & "InsertRange(3, input)") dinosaurs.InsertRange(3, input) Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "output = dinosaurs.GetRange(2, 3).ToArray") Dim output() As String = dinosaurs.GetRange(2, 3).ToArray() Console.WriteLine() For Each dinosaur As String In output Console.WriteLine(dinosaur) Next End Sub End Class ' This code example produces the following output: ' 'Capacity: 3 ' 'Brachiosaurus 'Amargasaurus 'Mamenchisaurus ' 'AddRange(dinosaurs) ' 'Brachiosaurus 'Amargasaurus 'Mamenchisaurus 'Brachiosaurus 'Amargasaurus 'Mamenchisaurus ' 'RemoveRange(2, 2) ' 'Brachiosaurus 'Amargasaurus 'Amargasaurus 'Mamenchisaurus ' 'InsertRange(3, input) ' 'Brachiosaurus 'Amargasaurus 'Amargasaurus 'Tyrannosaurus 'Deinonychus 'Velociraptor 'Mamenchisaurus ' 'output = dinosaurs.GetRange(2, 3).ToArray ' 'Amargasaurus 'Tyrannosaurus 'Deinonychus
using System; using System.Collections.Generic; public class Example { public static void Main() { string[] input = { "Brachiosaurus", "Amargasaurus", "Mamenchisaurus" }; List<string> dinosaurs = new List<string>(input); Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); Console.WriteLine(); foreach( string dinosaur in dinosaurs ) { Console.WriteLine(dinosaur); } Console.WriteLine("\nAddRange(dinosaurs)"); dinosaurs.AddRange(dinosaurs); Console.WriteLine(); foreach( string dinosaur in dinosaurs ) { Console.WriteLine(dinosaur); } Console.WriteLine("\nRemoveRange(2, 2)"); dinosaurs.RemoveRange(2, 2); Console.WriteLine(); foreach( string dinosaur in dinosaurs ) { Console.WriteLine(dinosaur); } input = new string[] { "Tyrannosaurus", "Deinonychus", "Velociraptor"}; Console.WriteLine("\nInsertRange(3, input)"); dinosaurs.InsertRange(3, input); Console.WriteLine(); foreach( string dinosaur in dinosaurs ) { Console.WriteLine(dinosaur); } Console.WriteLine("\noutput = dinosaurs.GetRange(2, 3).ToArray()"); string[] output = dinosaurs.GetRange(2, 3).ToArray(); Console.WriteLine(); foreach( string dinosaur in output ) { Console.WriteLine(dinosaur); } } } /* This code example produces the following output: Capacity: 3 Brachiosaurus Amargasaurus Mamenchisaurus AddRange(dinosaurs) Brachiosaurus Amargasaurus Mamenchisaurus Brachiosaurus Amargasaurus Mamenchisaurus RemoveRange(2, 2) Brachiosaurus Amargasaurus Amargasaurus Mamenchisaurus InsertRange(3, input) Brachiosaurus Amargasaurus Amargasaurus Tyrannosaurus Deinonychus Velociraptor Mamenchisaurus output = dinosaurs.GetRange(2, 3).ToArray() Amargasaurus Tyrannosaurus Deinonychus */
using namespace System; using namespace System::Collections::Generic; void main() { array<String^>^ input = { "Brachiosaurus", "Amargasaurus", "Mamenchisaurus" }; List<String^>^ dinosaurs = gcnew List<String^>((IEnumerable<String^>^) input); Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\nAddRange(dinosaurs)"); dinosaurs->AddRange(dinosaurs); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\nRemoveRange(2, 2)"); dinosaurs->RemoveRange(2, 2); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } input = gcnew array<String^> { "Tyrannosaurus", "Deinonychus", "Velociraptor"}; Console::WriteLine("\nInsertRange(3, (IEnumerable<String^>^) input)"); dinosaurs->InsertRange(3, (IEnumerable<String^>^) input); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\noutput = dinosaurs->GetRange(2, 3)->ToArray()"); array<String^>^ output = dinosaurs->GetRange(2, 3)->ToArray(); Console::WriteLine(); for each(String^ dinosaur in output ) { Console::WriteLine(dinosaur); } } /* This code example produces the following output: Capacity: 3 Brachiosaurus Amargasaurus Mamenchisaurus AddRange(dinosaurs) Brachiosaurus Amargasaurus Mamenchisaurus Brachiosaurus Amargasaurus Mamenchisaurus RemoveRange(2, 2) Brachiosaurus Amargasaurus Amargasaurus Mamenchisaurus InsertRange(3, (IEnumerable<String^>^) input) Brachiosaurus Amargasaurus Amargasaurus Tyrannosaurus Deinonychus Velociraptor Mamenchisaurus output = dinosaurs->GetRange(2, 3)->ToArray() Amargasaurus Tyrannosaurus Deinonychus */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List コンストラクタ
アセンブリ: System.Web.Mobile (system.web.mobile.dll 内)


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List ジェネリック クラス
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ Public Class List(Of T) Implements IList(Of T), ICollection(Of T), _ IEnumerable(Of T), IList, ICollection, _ IEnumerable
[SerializableAttribute] public class List<T> : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable
[SerializableAttribute] generic<typename T> public ref class List : IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable

List クラスは、ArrayList クラスとジェネリックに等価です。このクラスは、必要に応じてサイズが動的に増加する配列を使用して、IList ジェネリック インターフェイスを実装します。
List クラスは、等値比較演算子と順序比較演算子の両方を使用します。
-
Contains、IndexOf、LastIndexOf、Remove などのメソッドは、リスト要素の等値比較演算子を使用します。型 T の既定の等値比較演算子は、次のように決定されます。型 T が IEquatable ジェネリック インターフェイスを実装している場合、等値比較演算子はそのインターフェイスの Equals メソッドです。それ以外の場合、既定の等値比較演算子は Object.Equals(Object) です。
-
BinarySearch、Sort などのメソッドは、リスト要素の順序比較演算子を使用します。型 T の既定の比較演算子は、次のように決定されます。型 T が IComparable ジェネリック インターフェイスを実装している場合、既定の比較演算子はそのインターフェイスの CompareTo メソッドです。それ以外で、型 T が非ジェネリックの IComparable インターフェイスを実装している場合、既定の比較演算子はそのインターフェイスの CompareTo メソッドです。型 T がどちらのインターフェイスも実装していない場合、既定の比較演算子は存在せず、比較演算子または比較デリゲートを明示的に指定する必要があります。
List が並べ替えられることは保証されていません。List を並べ替える必要のある操作 (BinarySearch など) を実行する前に、List を並べ替える必要があります。
このコレクション内の要素は、整数インデックスを使用してアクセスできます。このコレクションのインデックスは 0 から始まります。
List は、null 参照 (Visual Basic では Nothing) を参照型に対して有効な値として受け取り、要素の重複を許可します。
パフォーマンスに関する考慮事項List クラスまたは ArrayList クラスのどちらを使用するかを決定する場合、両者の機能は類似していますが、List クラスは通常パフォーマンスが優れており、タイプ セーフであることも考慮してください。List クラスの型 T で参照型が使用される場合、2 つのクラスの動作は同じです。ただし、型 T で値型が使用される場合、実装とボックス化の実行を検討する必要があります。
型 T で値型が使用される場合、コンパイラはその値型のために List クラスの実装を生成します。つまり、List オブジェクトのリスト要素は、その要素が使用できるまでボックス化する必要はありません。約 500 のリスト要素が作成されると、ボックス化しないリスト要素が保存されたメモリは、そのクラス実装を生成するために使用されたメモリよりも大きくなります。
型 T で使用される値型が、IEquatable ジェネリック インターフェイスを実装していることを確認します。実装していない場合、Contains などのメソッドは、影響を受けるリスト要素をボックス化する Object.Equals(Object) メソッドを呼び出す必要があります。値型が IComparable インターフェイスを実装している場合、ソース コードを所有していれば、IComparable ジェネリック インターフェイスも実装して BinarySearch メソッドと Sort メソッドがリスト要素をボックス化しないようにします。ソース コードを所有していない場合は、IComparer オブジェクトを BinarySearch メソッドと Sort メソッドに渡します。
ArrayList クラスを使用したり、厳密に型指定されたラッパーのコレクションを独自に記述したりする代わりに、List クラスの型固有の実装を使用することには利点があります。その理由は、独自の実装では、既に .NET Framework が行っている動作を実行する必要があることです。また、共通言語ランタイムは MSIL (Microsoft Intermediate Language) コードとメタデータを共有できますが、独自の実装ではできないことも理由です。

List ジェネリック クラスのいくつかのプロパティおよびメソッドを使用したコード例を次に示します。既定のコンストラクタを使用して、容量が 0 の文字列のリストを作成します。Capacity プロパティが表示された後、Add メソッドを使用して複数の項目を追加します。項目がリストされ、Capacity プロパティが Count プロパティと共に再表示されて、必要に応じて容量が増加したことが示されます。
Contains メソッドを使用して、リストに項目が存在するかをテストし、Insert メソッドを使用して、リストの中間に新しい項目を挿入します。リストの内容が再表示されます。
既定の Item プロパティ (C# ではインデクサ) を使用して項目を取得し、Remove メソッドを使用して、以前に追加された重複している項目の最初のインスタンスを削除します。内容が再表示されます。Remove メソッドは、常に、見つかった最初のインスタンスを削除します。
TrimExcess メソッドを使用して、項目数と一致するように容量を削減します。Capacity プロパティと Count プロパティが表示されます。未使用の容量が全容量の 10% 未満であった場合、リストのサイズは変更されていません。
最後に、Clear メソッドを使用して、リストからすべての項目を削除し、Capacity プロパティと Count プロパティが表示されます。
Imports System Imports System.Collections.Generic Public Class Example Public Shared Sub Main() Dim dinosaurs As New List(Of String) Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) dinosaurs.Add("Tyrannosaurus") dinosaurs.Add("Amargasaurus") dinosaurs.Add("Mamenchisaurus") dinosaurs.Add("Deinonychus") dinosaurs.Add("Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) Console.WriteLine(vbLf & "Contains(""Deinonychus""): {0}", _ dinosaurs.Contains("Deinonychus")) Console.WriteLine(vbLf & "Insert(2, ""Compsognathus"")") dinosaurs.Insert(2, "Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next Console.WriteLine(vbLf & "dinosaurs(3): {0}", dinosaurs(3)) Console.WriteLine(vbLf & "Remove(""Compsognathus"")") dinosaurs.Remove("Compsognathus") Console.WriteLine() For Each dinosaur As String In dinosaurs Console.WriteLine(dinosaur) Next dinosaurs.TrimExcess() Console.WriteLine(vbLf & "TrimExcess()") Console.WriteLine("Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) dinosaurs.Clear() Console.WriteLine(vbLf & "Clear()") Console.WriteLine("Capacity: {0}", dinosaurs.Capacity) Console.WriteLine("Count: {0}", dinosaurs.Count) End Sub End Class ' This code example produces the following output: ' 'Capacity: 0 ' 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'Capacity: 8 'Count: 5 ' 'Contains("Deinonychus"): True ' 'Insert(2, "Compsognathus") ' 'Tyrannosaurus 'Amargasaurus 'Compsognathus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'dinosaurs(3): Mamenchisaurus ' 'Remove("Compsognathus") ' 'Tyrannosaurus 'Amargasaurus 'Mamenchisaurus 'Deinonychus 'Compsognathus ' 'TrimExcess() 'Capacity: 5 'Count: 5 ' 'Clear() 'Capacity: 5 'Count: 0
using System; using System.Collections.Generic; public class Example { public static void Main() { List<string> dinosaurs = new List<string>(); Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); dinosaurs.Add("Tyrannosaurus"); dinosaurs.Add("Amargasaurus"); dinosaurs.Add("Mamenchisaurus"); dinosaurs.Add("Deinonychus"); dinosaurs.Add("Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } Console.WriteLine("\nCapacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); Console.WriteLine("\nContains(\"Deinonychus\"): {0}" , dinosaurs.Contains("Deinonychus")); Console.WriteLine("\nInsert(2, \"Compsognathus\")"); dinosaurs.Insert(2, "Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } Console.WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]); Console.WriteLine("\nRemove(\"Compsognathus\")"); dinosaurs.Remove("Compsognathus"); Console.WriteLine(); foreach(string dinosaur in dinosaurs) { Console.WriteLine(dinosaur); } dinosaurs.TrimExcess(); Console.WriteLine("\nTrimExcess()"); Console.WriteLine("Capacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); dinosaurs.Clear(); Console.WriteLine("\nClear()"); Console.WriteLine("Capacity: {0}", dinosaurs.Capacity); Console.WriteLine("Count: {0}", dinosaurs.Count); } } /* This code example produces the following output: Capacity: 0 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus Capacity: 8 Count: 5 Contains("Deinonychus"): True Insert(2, "Compsognathus") Tyrannosaurus Amargasaurus Compsognathus Mamenchisaurus Deinonychus Compsognathus dinosaurs[3]: Mamenchisaurus Remove("Compsognathus") Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus TrimExcess() Capacity: 5 Count: 5 Clear() Capacity: 5 Count: 0 */
using namespace System; using namespace System::Collections::Generic; void main() { List<String^>^ dinosaurs = gcnew List<String^>(); Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); dinosaurs->Add("Tyrannosaurus"); dinosaurs->Add("Amargasaurus"); dinosaurs->Add("Mamenchisaurus"); dinosaurs->Add("Deinonychus"); dinosaurs->Add("Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\nCapacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); Console::WriteLine("\nContains(\"Deinonychus\"): {0}", dinosaurs->Contains("Deinonychus")); Console::WriteLine("\nInsert(2, \"Compsognathus\")"); dinosaurs->Insert(2, "Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } Console::WriteLine("\ndinosaurs[3]: {0}", dinosaurs[3]); Console::WriteLine("\nRemove(\"Compsognathus\")"); dinosaurs->Remove("Compsognathus"); Console::WriteLine(); for each(String^ dinosaur in dinosaurs ) { Console::WriteLine(dinosaur); } dinosaurs->TrimExcess(); Console::WriteLine("\nTrimExcess()"); Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); dinosaurs->Clear(); Console::WriteLine("\nClear()"); Console::WriteLine("Capacity: {0}", dinosaurs->Capacity); Console::WriteLine("Count: {0}", dinosaurs->Count); } /* This code example produces the following output: Capacity: 0 Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus Capacity: 8 Count: 5 Contains("Deinonychus"): True Insert(2, "Compsognathus") Tyrannosaurus Amargasaurus Compsognathus Mamenchisaurus Deinonychus Compsognathus dinosaurs[3]: Mamenchisaurus Remove("Compsognathus") Tyrannosaurus Amargasaurus Mamenchisaurus Deinonychus Compsognathus TrimExcess() Capacity: 5 Count: 5 Clear() Capacity: 5 Count: 0 */

System.Collections.Generic.List

この型の public static (Visual Basic では Shared) メンバは、スレッド セーフです。すべてのインスタンス メンバがスレッド セーフになるかどうかは保証されていません。
コレクションが変更されない限り、List では、複数の読み込み操作が同時に発生しても問題ありません。コレクションの列挙処理は、本質的にはスレッド セーフな処理ではありません。まれに 1 つ以上の書き込みアクセスによって列挙処理で競合が発生する場合、確実にスレッド セーフにするには、列挙処理が完了するまでコレクションをロックします。コレクションに対し複数のスレッドがアクセスして読み取りや書き込みを行うことができるようにするには、独自に同期化を実装する必要があります。

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


List プロパティ
List プロパティ



List メソッド


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Collections.Generic.IEnumerable<T>.GetEnumerator | コレクションを反復処理する列挙子を返します。 |
![]() | System.Collections.ICollection.CopyTo | ICollection の要素を Array にコピーします。Array の特定のインデックスからコピーが開始されます。 |
![]() | System.Collections.IEnumerable.GetEnumerator | コレクションを反復処理する列挙子を返します。 |
![]() | System.Collections.IList.Add | IList に項目を追加します。 |
![]() | System.Collections.IList.Contains | IList に特定の値が格納されているかどうかを判断します。 |
![]() | System.Collections.IList.IndexOf | IList 内での指定した項目のインデックスを調べます。 |
![]() | System.Collections.IList.Insert | 指定したインデックスの IList に項目を挿入します。 |
![]() | System.Collections.IList.Remove | IList 内で最初に見つかった特定のオブジェクトを削除します。 |

List メソッド



名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | このメンバの説明については、「IPostBackEventHandler.RaisePostBackEvent」を参照してください。 |

List メンバ
インデックスを使用してアクセスできる、厳密に型指定されたオブジェクトのリストを表します。リストの検索、並べ替え、および操作のためのメソッドを提供します。
List ジェネリック型で公開されるメンバを以下の表に示します。




名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Collections.Generic.IEnumerable<T>.GetEnumerator | コレクションを反復処理する列挙子を返します。 |
![]() | System.Collections.ICollection.CopyTo | ICollection の要素を Array にコピーします。Array の特定のインデックスからコピーが開始されます。 |
![]() | System.Collections.IEnumerable.GetEnumerator | コレクションを反復処理する列挙子を返します。 |
![]() | System.Collections.IList.Add | IList に項目を追加します。 |
![]() | System.Collections.IList.Contains | IList に特定の値が格納されているかどうかを判断します。 |
![]() | System.Collections.IList.IndexOf | IList 内での指定した項目のインデックスを調べます。 |
![]() | System.Collections.IList.Insert | 指定したインデックスの IList に項目を挿入します。 |
![]() | System.Collections.IList.Remove | IList 内で最初に見つかった特定のオブジェクトを削除します。 |
![]() | System.Collections.IList.Item | 指定したインデックスにある要素を取得または設定します。 |

List メンバ
静的な表示または対話操作が可能なリストとして、項目のリストを描画します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | ItemCommand | List コントロールに関連付けられているコマンドをユーザーが選択すると発生します。 |
![]() | ItemDataBind | List 内の項目がデータにバインドされたときに発生します。 |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | LoadItems | コントロールの改ページ位置が自動修正され、さらにデータを必要とする場合に発生します。(PagedControl から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | このメンバの説明については、「IPostBackEventHandler.RaisePostBackEvent」を参照してください。 |

List
list
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2020/08/24 00:03 UTC 版)
「Hyper Estraier」の記事における「list」の解説
※この「list」の解説は、「Hyper Estraier」の解説の一部です。
「list」を含む「Hyper Estraier」の記事については、「Hyper Estraier」の概要を参照ください。
「list」の例文・使い方・用例・文例
固有名詞の分類
「list」に関係したコラム
FXのチャート分析ソフトMT4のインディケーターを提供しているWebサイトの一覧
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)のインディケーターを提供しているWebサイトの一覧です。インディケーターのファイル形式は、「.mq4」、あるいは、「....
FXのチャート分析ソフトMT4で10分足や2時間足などを表示するには
FX(外国為替証拠金取引)のチャート分析ソフトMT4(Meta Trader 4)では、次の時間足の表示ができます。ティック1分足5分足15分足30分足1時間足4時間足日足週足MT4では、10分足や1...
- listのページへのリンク