SortedList.System.Collections.IDictionary.Remove メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > SortedList.System.Collections.IDictionary.Remove メソッドの意味・解説 

SortedList.System.Collections.IDictionary.Remove メソッド

メモ : このメソッドは、.NET Framework version 2.0新しく追加されたものです。

指定したキー持つ要素を IDictionary から削除します

名前空間: System.Collections.Generic
アセンブリ: System (system.dll 内)
構文構文

Private Sub System.Collections.IDictionary.Remove
 ( _
    key As Object _
) Implements IDictionary.Remove
Dim instance As SortedList(Of
 TKey, TValue)
Dim key As Object

CType(instance, IDictionary).Remove(key)
void IDictionary.Remove (
    Object key
)
private:
virtual void System.Collections.IDictionary.Remove (
    Object^ key
) sealed = IDictionary::Remove

パラメータ

key

削除する要素キー

例外例外
例外種類条件

ArgumentNullException

keynull 参照 (Visual Basic では Nothing) です。

解説解説

このメソッドは、バイナリ サーチ実行しますが、空いている位置埋めるために要素位置上がるため、このメソッドは O(n) 操作です。ここで、n は、Count です。

使用例使用例

SortedList で System.Collections.IDictionary インターフェイスSystem.Collections.IDictionary.Remove使用する方法次のコード例示します

次のコード例は、System.Collections.IDictionary.Add メソッドトピック取り上げている例および出力一部分です。

Imports System
Imports System.Collections
Imports System.Collections.Generic

Public Class Example
    
    Public Shared Sub Main()
 

        ' Create a new sorted list of strings, with string keys,
        ' and access it using the IDictionary interface.
        '
        Dim openWith As IDictionary = _
            New sortedList(Of String,
 String)
        
        ' Add some elements to the sorted list. There are no 
        ' duplicate keys, but some of the values are duplicates.
        ' IDictionary.Add throws an exception if incorrect types
        ' are supplied for key or value.
        openWith.Add("txt", "notepad.exe")
        openWith.Add("bmp", "paint.exe")
        openWith.Add("dib", "paint.exe")
        openWith.Add("rtf", "wordpad.exe")
<br /><span space="preserve">...</span><br
 />        ' Use the Remove method to remove a key/value pair. No
        ' exception is thrown if the wrong data type is supplied.
        Console.WriteLine(vbLf + "Remove(""dib"")")
        openWith.Remove("dib")
        
        If Not openWith.Contains("dib")
 Then
            Console.WriteLine("Key ""dib""
 is not found.")
        End If
<br /><span space="preserve">...</span><br
 />
    End Sub

End Class
using System;
using System.Collections;
using System.Collections.Generic;

public class Example
{
    public static void Main()
    {
        // Create a new sorted list of strings, with string keys,
        // and access it using the IDictionary interface.
        //
        IDictionary openWith = new SortedList<string,
 string>();

        // Add some elements to the sorted list. There are no 
        // duplicate keys, but some of the values are duplicates.
        // IDictionary.Add throws an exception if incorrect types
        // are supplied for key or value.
        openWith.Add("txt", "notepad.exe");
        openWith.Add("bmp", "paint.exe");
        openWith.Add("dib", "paint.exe");
        openWith.Add("rtf", "wordpad.exe");
<br /><span space="preserve">...</span><br /> 
       // Use the Remove method to remove a key/value pair. No
        // exception is thrown if the wrong data type is supplied.
        Console.WriteLine("\nRemove(\"dib\")");
        openWith.Remove("dib");

        if (!openWith.Contains("dib"))
        {
            Console.WriteLine("Key \"dib\" is not found.");
        }
<br /><span space="preserve">...</span><br /> 
   }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
SortedList ジェネリック クラス
SortedList メンバ
System.Collections.Generic 名前空間
SortedList.Remove メソッド
SortedList.RemoveAt メソッド



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

SortedList.System.Collections.IDictionary.Remove メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SortedList.System.Collections.IDictionary.Remove メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS