SortedList.GetValueList メソッドとは? わかりやすく解説

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

SortedList.GetValueList メソッド

SortedList 内の値を取得します。

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

Public Overridable Function
 GetValueList As IList
Dim instance As SortedList
Dim returnValue As IList

returnValue = instance.GetValueList
public virtual IList GetValueList ()
public:
virtual IList^ GetValueList ()
public IList GetValueList ()
public function GetValueList () : IList

戻り値
SortedList 内の値を格納している IList。

解説解説

返された IList は、SortedList の値の読み取り専用ビューです。基になる SortedList が変更されると、その変更はすぐに IList に反映されます。

返された IList の要素は、SortedList の値と同じ順序で並べ替えられます。

Values に類似していますが、ICollection ではなく IList を返します。

このメソッドは O(1) 操作です。

使用例使用例

SortedList 内のキーまたは値を個別にまたは一括して取得する方法の例を次に示します。

Imports System
Imports System.Collections
Imports Microsoft.VisualBasic

Public Class SamplesSortedList
        
    Public Shared Sub Main()
        
        ' Creates and initializes a new SortedList.
        Dim mySL As New
 SortedList()
        mySL.Add(1.3, "fox")
        mySL.Add(1.4, "jumped")
        mySL.Add(1.5, "over")
        mySL.Add(1.2, "brown")
        mySL.Add(1.1, "quick")
        mySL.Add(1.0, "The")
        mySL.Add(1.6, "the")
        mySL.Add(1.8, "dog")
        mySL.Add(1.7, "lazy")
        
        ' Gets the key and the value based on the index.
        Dim myIndex As Integer
 = 3
        Console.WriteLine("The key   at index {0} is {1}.",
 myIndex, _
           mySL.GetKey(myIndex))
        Console.WriteLine("The value at index {0} is {1}.",
 myIndex, _
           mySL.GetByIndex(myIndex))
        
        ' Gets the list of keys and the list of values.
        Dim myKeyList As IList = mySL.GetKeyList()
        Dim myValueList As IList = mySL.GetValueList()
        
        ' Prints the keys in the first column and the values in the
 second column.
        Console.WriteLine(ControlChars.Tab & "-KEY-"
 & ControlChars.Tab & _
           "-VALUE-")
        Dim i As Integer
        For i = 0 To mySL.Count - 1
            Console.WriteLine(ControlChars.Tab & "{0}"
 & ControlChars.Tab & _
               "{1}", myKeyList(i), myValueList(i))
        Next i
    End Sub
End Class

' This code produces the following output.
' 
' The key   at index 3 is 1.3.
' The value at index 3 is fox.
'     -KEY-    -VALUE-
'     1    The
'     1.1    quick
'     1.2    brown
'     1.3    fox
'     1.4    jumped
'     1.5    over
'     1.6    the
'     1.7    lazy
'     1.8    dog
using System;
using System.Collections;
public class SamplesSortedList  {

   public static void Main()
  {

      // Creates and initializes a new SortedList.
      SortedList mySL = new SortedList();
      mySL.Add( 1.3, "fox" );
      mySL.Add( 1.4, "jumped" );
      mySL.Add( 1.5, "over" );
      mySL.Add( 1.2, "brown" );
      mySL.Add( 1.1, "quick" );
      mySL.Add( 1.0, "The" );
      mySL.Add( 1.6, "the" );
      mySL.Add( 1.8, "dog" );
      mySL.Add( 1.7, "lazy" );

      // Gets the key and the value based on the index.
      int myIndex=3;
      Console.WriteLine( "The key   at index {0} is {1}.", myIndex, mySL.GetKey(
 myIndex ) );
      Console.WriteLine( "The value at index {0} is {1}.", myIndex, mySL.GetByIndex(
 myIndex ) );

      // Gets the list of keys and the list of values.
      IList myKeyList = mySL.GetKeyList();
      IList myValueList = mySL.GetValueList();

      // Prints the keys in the first column and the values in the second
 column.
      Console.WriteLine( "\t-KEY-\t-VALUE-" );
      for ( int i = 0; i < mySL.Count; i++
 )
         Console.WriteLine( "\t{0}\t{1}", myKeyList[i], myValueList[i]
 );
   }
}
/* 
This code produces the following output.

The key   at index 3 is 1.3.
The value at index 3 is fox.
    -KEY-    -VALUE-
    1    The
    1.1    quick
    1.2    brown
    1.3    fox
    1.4    jumped
    1.5    over
    1.6    the
    1.7    lazy
    1.8    dog
*/ 
#using <system.dll>

using namespace System;
using namespace System::Collections;
int main()
{
   
   // Creates and initializes a new SortedList.
   SortedList^ mySL = gcnew SortedList;
   mySL->Add( 1.3, "fox" );
   mySL->Add( 1.4, "jumped" );
   mySL->Add( 1.5, "over" );
   mySL->Add( 1.2, "brown" );
   mySL->Add( 1.1, "quick" );
   mySL->Add( 1.0, "The" );
   mySL->Add( 1.6, "the" );
   mySL->Add( 1.8, "dog" );
   mySL->Add( 1.7, "lazy" );
   
   // Gets the key and the value based on the index.
   int myIndex = 3;
   Console::WriteLine( "The key   at index {0} is {1}.", myIndex, mySL->GetKey(
 myIndex ) );
   Console::WriteLine( "The value at index {0} is {1}.", myIndex, mySL->GetByIndex(
 myIndex ) );
   
   // Gets the list of keys and the list of values.
   IList^ myKeyList = mySL->GetKeyList();
   IList^ myValueList = mySL->GetValueList();
   
   // Prints the keys in the first column and the values in the second
 column.
   Console::WriteLine( "\t-KEY-\t-VALUE-" );
   for ( int i = 0; i < mySL->Count;
 i++ )
      Console::WriteLine( "\t{0}\t{1}", myKeyList[ i ], myValueList[ i
 ] );
}

/*
This code produces the following output.

The key   at index 3 is 1.3.
The value at index 3 is fox.
        -KEY-   -VALUE-
        1       The
        1.1     quick
        1.2     brown
        1.3     fox
        1.4     jumped
        1.5     over
        1.6     the
        1.7     lazy
        1.8     dog
*/
import System.*;
import System.Collections.*;

public class SamplesSortedList
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a new SortedList.
        SortedList mySL = new SortedList();

        mySL.Add((System.Single)1.3, "fox");
        mySL.Add((System.Single)1.4, "jumped");
        mySL.Add((System.Single)1.5, "over");
        mySL.Add((System.Single)1.2, "brown");
        mySL.Add((System.Single)1.1, "quick");
        mySL.Add((System.Single)1.0, "The");
        mySL.Add((System.Single)1.6, "the");
        mySL.Add((System.Single)1.8, "dog");
        mySL.Add((System.Single)1.7, "lazy");

        // Gets the key and the value based on the index.
        int myIndex = 3;

        Console.WriteLine("The key   at index {0} is {1}.", 
            System.Convert.ToString(myIndex), mySL.GetKey(myIndex));
        Console.WriteLine("The value at index {0} is {1}.", 
            System.Convert.ToString(myIndex), mySL.GetByIndex(myIndex));

        // Gets the list of keys and the list of values.
        IList myKeyList = mySL.GetKeyList();
        IList myValueList = mySL.GetValueList();

        // Prints the keys in the first column and the values in the
 
        // second column.
        Console.WriteLine("\t-KEY-\t-VALUE-");
        for (int i = 0; i < mySL.get_Count();
 i++) {
            Console.WriteLine("\t{0}\t{1}", myKeyList.get_Item(i), 
                myValueList.get_Item(i));
        }
    } //main
} //SamplesSortedList

/* 
 This code produces the following output.
 
 The key   at index 3 is 1.3.
 The value at index 3 is fox.
     -KEY-    -VALUE-
     1    The
     1.1    quick
     1.2    brown
     1.3    fox
     1.4    jumped
     1.5    over
     1.6    the
     1.7    lazy
     1.8    dog
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

SortedList.GetValueList メソッドのお隣キーワード
検索ランキング

   

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



SortedList.GetValueList メソッドのページの著作権

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

©2026 GRAS Group, Inc.RSS