queueとは? わかりやすく解説

queue

別表記:キュー

「queue」とは、行列順番待ち記載するリスト行列に並ぶなどのことを意味する英語表現である。

「queue」とは・「queue」の意味

「queue」とは、「行列順番待ち記載するリスト」という名詞や「行列に並ぶ」という動詞の意味を持つ英単語である。「行列」といった意味はイギリス英語圏で使われる表現で、アメリカ英語圏では「line」を使うため、「queue」を用いて伝わらないことも珍しくない例えば「ここで並んでお待ちくださいと言う場合イギリス英語圏では「Please wait in queue here.」となるが、アメリカ英語圏では「Please wait in line here.」と表現異なってくる可能性がある。

IT用語としての「queue(待ち行列)」はデータ構造名として用いられている。「データ構造」とはデータ格納し任意のタイミングデータ取り出すことのできる器のことを意味する。「queue」においては、「先に入れたデータを、順番取り出す」という構造になっている。そのデータ動きから「First-In First-OUTFIFO方式」とも呼ばれるまた、この「queue(キュー)」を用いて要素管理することを「queuingキューイング)」と言う

なお、同音異義語として「que」があるが、これは「Quebecカナダケベック州)」の略称である。

「queue」の複数形

「queue」の複数形は「queues」である。

「queue」のスラングとしての意味

「queue」の一般的なスラングは特にないが、ネット・ゲーム用語として対戦相手とのマッチング待機中」を示す際に「queue」が使われており、「Q」や「que」と略されることもある。また「solo queuesolo Q)」は「単独参加登録をしてマッチング待機中」といった意味を持つ。更に、WEBログサービスTumblrタンブラー)」において、「queue」とタグ付けをされることがある。これは、Tumblr提供するQueued post」という機能利用して予約投稿自動投稿をした場合など付与されるタグである。

「queue」の発音・読み方

「queue」の発音記号は「kjuː」であり、カタカナ読みすると「キュー」となる。

「queue」の活用変化一覧

「queue」は、三人称単数現在形「queues」、現在分詞「queueing」あるいは「queuing」、過去形過去分詞形「queued」と変化する

「queue」の語源・由来

「queue」は、「尻尾」を意味するフランス語「queue」から転じたのであるとされる

「queue」の覚え方

「queue」の覚え方としては、「9(キュー)人が列を作る」や「9(キュー)人の行列」といった語呂合わせがある。

「queue」を含む英熟語・英語表現

「queue up」とは


「queue up」とは、「列を作る、列に並ぶ、並んで立つ」といった意味を持つ英語表現である。「queue up for A」となると、「列に並んでAを待つ」という意味になる。

「in queue」とは


「in queue」とは、ゲーム用語であり、「対戦相手とのオンラインでのマッチング待っている状態」を意味する言葉である。英語の文法としては誤りであり、本来は「in the queue」や「in a queue」が適切な表現となる。なお、「in Q」と省略することも多い。

「queue」を含む用語の解説

「queue(python)」とは


「queue(python)」とはプログラミング言語python」の標準ライブラリ含まれているモジュール名である。IT用語における「queue」はデータ構造一つであり、「先入先出キューFIFO)」のことを意味するが、pythonにおけるqueueモジュールにおいては、「先入先出キューFIFO)」だけでなく、「後入先出キューLIFO)」および「優先順位付きキュー」の三種類を含んでいる。

「queue」の使い方・例文

「queue」は一般的には「列」あるいは「列に並ぶ」という意味で用いられる例文としては、「We waited in queue for an hour.(私たちは列に並んで一時間待ちました)」や「There is a long queue waiting outside the shop.(店舗の外には長い行列ができている)」といった表現となる。また、「queue」に「jump」を追加することで「列に横から割り込む」という表現が可能となる。例えば「The woman jumped the queue.(その女性は割り込みをした)」、「Hey, no queue-jumping!(おい、割り込みするな!)」といった使い方ができる。

IT用語として用い場合は、「Does the queue contain the data?(キューにはデータ含まれますか?)」や「Returns a queue task to active state.(キュータスクをアクティブに戻す)」、「There has been an error queuing your print job.(印刷ジョブキュー登録する時、エラーになった)」などと使うことができる。

キュー【Q/q】

読み方:きゅー

英語のアルファベットの第17字。

Q〉《quality factor電気回路における共振鋭さを表す値。

〈Q〉大きなエネルギーの単位。1Q=2.52×1017kcalで、石炭360トン燃やしたときの熱量に相当。

〈Q〉《question疑問質問問題略号。「—アンドA」

〈Q〉《queen》チェス・トランプで、クイーン記号

〈Q〉《quarter四半期決算での、1つの期。

《「級(きゅう)」の音から》写真植字級数を表す俗な略号

〈q〉《(フランス)queue》染色体長腕を表す記号。12qは12番染色体長腕意味する


キュー【queue】


Queue キュー

外部からかかってきたすべてのインバウンドコールをACD機能により一旦保留すること。着信コール順番に手のあいたTSR次々と接続できるFIFO(First‐In/First-Out)という記憶方式により、先にかかった電話から順番分配する

Queue クラス

オブジェクト先入れ先出しコレクション表します

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

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class Queue
    Implements ICollection, IEnumerable, ICloneable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class Queue : ICollection, IEnumerable,
 ICloneable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class Queue : ICollection, IEnumerable,
 ICloneable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class Queue implements ICollection,
 IEnumerable, 
    ICloneable
SerializableAttribute 
ComVisibleAttribute(true) 
public class Queue implements ICollection,
 IEnumerable, 
    ICloneable
解説解説
使用例使用例

Queue作成して値を追加する方法と、その値を出力する方法の例を次に示します

Imports System
Imports System.Collections

Public Class SamplesQueue

    Public Shared Sub Main()

        ' Creates and initializes a new Queue.
        Dim myQ As New Queue()
        myQ.Enqueue("Hello")
        myQ.Enqueue("World")
        myQ.Enqueue("!")

        ' Displays the properties and values of the Queue.
        Console.WriteLine("myQ")
        Console.WriteLine("    Count:    {0}", myQ.Count)
        Console.Write("    Values:")
        PrintValues(myQ)

    End Sub 'Main

    Public Shared Sub PrintValues(myCollection
 As IEnumerable)
        Dim obj As [Object]
        For Each obj In
  myCollection
            Console.Write("    {0}", obj)
        Next obj
        Console.WriteLine()
    End Sub 'PrintValues

End Class 'SamplesQueue


' This code produces the following output.
' 
' myQ
'     Count:    3
'     Values:    Hello    World    !

 using System;
 using System.Collections;
 public class SamplesQueue  {
 
    public static void Main()
  {
 
       // Creates and initializes a new Queue.
       Queue myQ = new Queue();
       myQ.Enqueue("Hello");
       myQ.Enqueue("World");
       myQ.Enqueue("!");
 
       // Displays the properties and values of the Queue.
       Console.WriteLine( "myQ" );
       Console.WriteLine( "\tCount:    {0}", myQ.Count );
       Console.Write( "\tValues:" );
       PrintValues( myQ );
    }
 
 
    public static void PrintValues(
 IEnumerable myCollection )  {
       foreach ( Object obj in myCollection
 )
          Console.Write( "    {0}", obj );
       Console.WriteLine();
    }
 }
 /* 
 This code produces the following output.
 
 myQ
     Count:    3
     Values:    Hello    World    !
*/ 
using namespace System;
using namespace System::Collections;
void PrintValues( IEnumerable^ myCollection );
int main()
{
   
   // Creates and initializes a new Queue.
   Queue^ myQ = gcnew Queue;
   myQ->Enqueue( "Hello" );
   myQ->Enqueue( "World" );
   myQ->Enqueue( "!" );
   
   // Displays the properties and values of the Queue.
   Console::WriteLine( "myQ" );
   Console::WriteLine( "\tCount:    {0}", myQ->Count );
   Console::Write( "\tValues:" );
   PrintValues( myQ );
}

void PrintValues( IEnumerable^ myCollection )
{
   IEnumerator^ myEnum = myCollection->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      Object^ obj = safe_cast<Object^>(myEnum->Current);
      Console::Write( "    {0}", obj );
   }

   Console::WriteLine();
}

/* 
 This code produces the following output.
 
 myQ
     Count:    3
     Values:    Hello    World    !
*/
import System.*;
import System.Collections.*;

public class SamplesQueue
{
    public static void main(String[]
 args)
    {
        // Creates and initializes a new Queue.
        Queue myQ = new Queue();
        myQ.Enqueue("Hello");
        myQ.Enqueue("World");
        myQ.Enqueue("!");

        // Displays the properties and values of the Queue.
        Console.WriteLine("myQ");
        Console.WriteLine(
            "\tCount:    {0}",System.Convert.ToString(myQ.get_Count()));
        Console.Write("\tValues:");
        PrintValues(myQ);
    } //main

    public static void PrintValues(IEnumerable
 myCollection)
    {
        IEnumerator enumerator = myCollection.GetEnumerator();
        while(enumerator.MoveNext()) {
            Object obj = enumerator.get_Current();
            Console.Write("    {0}", obj);
        }
        Console.WriteLine();
    } //PrintValues
} //SamplesQueue

/* 
 This code produces the following output.
 
 myQ
     Count:    3
     Values:    Hello    World    !
 */
継承階層継承階層
System.Object
  System.Collections.Queue
スレッド セーフスレッド セーフ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Queue メンバ
System.Collections 名前空間
System.Collections.Generic.Queue

Queue コンストラクタ ()

空で、既定初期量を備え既定増加率使用する、Queue クラス新しインスタンス初期化します。

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

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、既定初期量を備えた、Queue クラス新しインスタンス初期化します。

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

解説解説
使用例使用例

このコンストラクタおよび Queue ジェネリック クラスのその他いくつかのメソッド使用したコード例次に示します。このコード例では、既定容量文字列キュー作成しEnqueue メソッド使用して 5 つ文字列キュー置きますキュー要素列挙されますが、キューの状態は変化しません。Dequeue メソッド使用して最初文字列キューから取り出しますPeek メソッド使用してキュー内の次の項目を調べてから、Dequeue メソッド使用してキューから取り出します

ToArray メソッド使用して配列作成し、その配列キュー要素コピーしてから、IEnumerable を受け取る Queue コンストラクタ配列渡してキューコピー作成しますコピー要素表示されます。

キューの 2 倍のサイズ配列作成されCopyTo メソッド使用して配列中央部で始まる配列要素コピーしますQueue コンストラクタ再度使用して先頭3 つの null 要素を含むキュー2 つ目のコピー作成します

Contains メソッドにより、文字列 "four" がキュー最初コピー含まれていることを示しますその後で、Clear メソッドコピークリアすると、Count プロパティによってキューが空であることが示されます。

Imports System
Imports System.Collections.Generic

Module Example

    Sub Main

        Dim numbers As New
 Queue(Of String)
        numbers.Enqueue("one")
        numbers.Enqueue("two")
        numbers.Enqueue("three")
        numbers.Enqueue("four")
        numbers.Enqueue("five")

        ' A queue can be enumerated without disturbing its contents.
        For Each number As
 String In numbers
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "Dequeuing '{0}'", numbers.Dequeue())
        Console.WriteLine("Peek at next item to dequeue: {0}",
 _
            numbers.Peek())    
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue())

        ' Create a copy of the queue, using the ToArray method and the
        ' constructor that accepts an IEnumerable(Of T).
        Dim queueCopy As New
 Queue(Of String)(numbers.ToArray())

        Console.WriteLine(vbLf & "Contents of the first copy:")
        For Each number As
 String In queueCopy
            Console.WriteLine(number)
        Next
        
        ' Create an array twice the size of the queue, compensating
        ' for the fact that Visual Basic allocates an extra array 
        ' element. Copy the elements of the queue, starting at the
        ' middle of the array. 
        Dim array2((numbers.Count * 2) - 1) As
 String
        numbers.CopyTo(array2, numbers.Count)
        
        ' Create a second queue, using the constructor that accepts
 an
        ' IEnumerable(Of T).
        Dim queueCopy2 As New
 Queue(Of String)(array2)

        Console.WriteLine(vbLf & _
            "Contents of the second copy, with duplicates and
 nulls:")
        For Each number As
 String In queueCopy2
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "queueCopy.Contains(""four"")
 = {0}", _
            queueCopy.Contains("four"))

        Console.WriteLine(vbLf & "queueCopy.Clear()")
        queueCopy.Clear()
        Console.WriteLine(vbLf & "queueCopy.Count = {0}",
 _
            queueCopy.Count)
    End Sub
End Module

' This code example produces the following output:
'
'one
'two
'three
'four
'five
'
'Dequeuing 'one'
'Peek at next item to dequeue: two
'
'Dequeuing 'two'
'
'Contents of the copy:
'three
'four
'five
'
'Contents of the second copy, with duplicates and nulls:
'
'
'
'three
'four
'five
'
'queueCopy.Contains("four") = True
'
'queueCopy.Clear()
'
'queueCopy.Count = 0
using System;
using System.Collections.Generic;

class Example
{
    public static void Main()
    {
        Queue<string> numbers = new Queue<string>();
        numbers.Enqueue("one");
        numbers.Enqueue("two");
        numbers.Enqueue("three");
        numbers.Enqueue("four");
        numbers.Enqueue("five");

        // A queue can be enumerated without disturbing its contents.
        foreach( string number in
 numbers )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nDequeuing '{0}'", numbers.Dequeue());
        Console.WriteLine("Peek at next item to dequeue: {0}", 
            numbers.Peek());
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue());

        // Create a copy of the queue, using the ToArray method and
 the
        // constructor that accepts an IEnumerable<T>.
        Queue<string> queueCopy = new
 Queue<string>(numbers.ToArray());

        Console.WriteLine("\nContents of the first copy:");
        foreach( string number in
 queueCopy )
        {
            Console.WriteLine(number);
        }
        
        // Create an array twice the size of the queue and copy the
        // elements of the queue, starting at the middle of the 
        // array. 
        string[] array2 = new string[numbers.Count
 * 2];
        numbers.CopyTo(array2, numbers.Count);
        
        // Create a second queue, using the constructor that accepts
 an
        // IEnumerable(Of T).
        Queue<string> queueCopy2 = new
 Queue<string>(array2);

        Console.WriteLine("\nContents of the second copy, with duplicates and
 nulls:");
        foreach( string number in
 queueCopy2 )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nqueueCopy.Contains(\"four\") = {0}",
 
            queueCopy.Contains("four"));

        Console.WriteLine("\nqueueCopy.Clear()");
        queueCopy.Clear();
        Console.WriteLine("\nqueueCopy.Count = {0}", queueCopy.Count);
    }
}

/* This code example produces the following output:

one
two
three
four
five

Dequeuing 'one'
Peek at next item to dequeue: two
Dequeuing 'two'

Contents of the copy:
three
four
five

Contents of the second copy, with duplicates and nulls:



three
four
five

queueCopy.Contains("four") = True

queueCopy.Clear()

queueCopy.Count = 0
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ (Int32, Single)

空で、指定した初期量を備え指定した増加率使用するQueue クラス新しインスタンス初期化します。

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

Public Sub New ( _
    capacity As Integer, _
    growFactor As Single _
)
Dim capacity As Integer
Dim growFactor As Single

Dim instance As New Queue(capacity,
 growFactor)
public Queue (
    int capacity,
    float growFactor
)
public:
Queue (
    int capacity, 
    float growFactor
)
public Queue (
    int capacity, 
    float growFactor
)
public function Queue (
    capacity : int, 
    growFactor : float
)

パラメータ

capacity

Queue が格納できる要素数の初期値

growFactor

Queue容量拡張するときに使用する係数

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

または

growFactor1.0 未満であるか、10.0超えてます。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ (Int32)

空で、指定した初期量を備え既定増加率使用するQueue クラス新しインスタンス初期化します。

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

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ (Int32)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

空で、指定した初期量を備えたQueue クラス新しインスタンス初期化します。

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

例外例外
例外種類条件

ArgumentOutOfRangeException

capacity が 0 未満です。

解説解説

Queue容量は、Queue保持できる要素数になりますQueue要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、Queue要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

容量を減らすには、TrimExcess を呼び出します。

このコンストラクタは O(n) 操作です。ここで、ncapacity です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ (ジェネリック IEnumerable)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

指定したコレクションからコピーした要素格納しコピーされる要素の数を格納できるだけの容量備えたQueue クラス新しインスタンス初期化します。

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

Public Sub New ( _
    collection As IEnumerable(Of T) _
)
Dim collection As IEnumerable(Of
 T)

Dim instance As New Queue(Of
 T)(collection)
public Queue (
    IEnumerable<T> collection
)
public:
Queue (
    IEnumerable<T>^ collection
)
public Queue (
    IEnumerable<T> collection
)
public function Queue (
    collection : IEnumerable<T>
)

パラメータ

collection

新しい Queue に要素コピーされコレクション

例外例外
例外種類条件

ArgumentNullException

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

解説解説

Queue容量は、Queue保持できる要素数になりますQueue要素追加すると、必要に応じて内部配列の再割り当てによって容量自動的に増加します。

コレクションサイズ推定できる場合は、初期量を指定すると、Queue要素追加するときに、サイズ変更操作何度も実行する必要がなくなります

容量を減らすには、TrimExcess を呼び出します。

要素は、コレクションの IEnumerator によって読み取られる順序と同じ順序で、Queueコピーされます。

このコンストラクタは O(n) 操作です。ここで、ncollection 内の要素数です。

使用例使用例

このコンストラクタおよび Queue ジェネリック クラスのその他いくつかのメソッド使用したコード例次に示します。このコード例では、既定容量文字列キュー作成しEnqueue メソッド使用して 5 つ文字列キュー置きますキュー要素列挙されますが、キューの状態は変化しません。Dequeue メソッド使用して最初文字列キューから取り出しますPeek メソッド使用してキュー内の次の項目を調べてから、Dequeue メソッド使用してキューから取り出します

ToArray メソッド使用して配列作成し、その配列キュー要素コピーしてから、IEnumerable を受け取Queue コンストラクタ配列渡してキューコピー作成しますコピー要素表示されます。

キューの 2 倍のサイズ配列作成されCopyTo メソッド使用して配列中央部で始まる配列要素コピーしますQueue コンストラクタ再度使用して先頭3 つの null 要素を含むキュー2 つ目のコピー作成します

Contains メソッドにより、文字列 "four" がキュー最初コピー含まれていることを示しますその後で、Clear メソッドコピークリアすると、Count プロパティによってキューが空であることが示されます。

Imports System
Imports System.Collections.Generic

Module Example

    Sub Main

        Dim numbers As New
 Queue(Of String)
        numbers.Enqueue("one")
        numbers.Enqueue("two")
        numbers.Enqueue("three")
        numbers.Enqueue("four")
        numbers.Enqueue("five")

        ' A queue can be enumerated without disturbing its contents.
        For Each number As
 String In numbers
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "Dequeuing '{0}'", numbers.Dequeue())
        Console.WriteLine("Peek at next item to dequeue: {0}",
 _
            numbers.Peek())    
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue())

        ' Create a copy of the queue, using the ToArray method and the
        ' constructor that accepts an IEnumerable(Of T).
        Dim queueCopy As New
 Queue(Of String)(numbers.ToArray())

        Console.WriteLine(vbLf & "Contents of the first copy:")
        For Each number As
 String In queueCopy
            Console.WriteLine(number)
        Next
        
        ' Create an array twice the size of the queue, compensating
        ' for the fact that Visual Basic allocates an extra array 
        ' element. Copy the elements of the queue, starting at the
        ' middle of the array. 
        Dim array2((numbers.Count * 2) - 1) As
 String
        numbers.CopyTo(array2, numbers.Count)
        
        ' Create a second queue, using the constructor that accepts
 an
        ' IEnumerable(Of T).
        Dim queueCopy2 As New
 Queue(Of String)(array2)

        Console.WriteLine(vbLf & _
            "Contents of the second copy, with duplicates and
 nulls:")
        For Each number As
 String In queueCopy2
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "queueCopy.Contains(""four"")
 = {0}", _
            queueCopy.Contains("four"))

        Console.WriteLine(vbLf & "queueCopy.Clear()")
        queueCopy.Clear()
        Console.WriteLine(vbLf & "queueCopy.Count = {0}",
 _
            queueCopy.Count)
    End Sub
End Module

' This code example produces the following output:
'
'one
'two
'three
'four
'five
'
'Dequeuing 'one'
'Peek at next item to dequeue: two
'
'Dequeuing 'two'
'
'Contents of the copy:
'three
'four
'five
'
'Contents of the second copy, with duplicates and nulls:
'
'
'
'three
'four
'five
'
'queueCopy.Contains("four") = True
'
'queueCopy.Clear()
'
'queueCopy.Count = 0
using System;
using System.Collections.Generic;

class Example
{
    public static void Main()
    {
        Queue<string> numbers = new Queue<string>();
        numbers.Enqueue("one");
        numbers.Enqueue("two");
        numbers.Enqueue("three");
        numbers.Enqueue("four");
        numbers.Enqueue("five");

        // A queue can be enumerated without disturbing its contents.
        foreach( string number in
 numbers )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nDequeuing '{0}'", numbers.Dequeue());
        Console.WriteLine("Peek at next item to dequeue: {0}", 
            numbers.Peek());
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue());

        // Create a copy of the queue, using the ToArray method and
 the
        // constructor that accepts an IEnumerable<T>.
        Queue<string> queueCopy = new
 Queue<string>(numbers.ToArray());

        Console.WriteLine("\nContents of the first copy:");
        foreach( string number in
 queueCopy )
        {
            Console.WriteLine(number);
        }
        
        // Create an array twice the size of the queue and copy the
        // elements of the queue, starting at the middle of the 
        // array. 
        string[] array2 = new string[numbers.Count
 * 2];
        numbers.CopyTo(array2, numbers.Count);
        
        // Create a second queue, using the constructor that accepts
 an
        // IEnumerable(Of T).
        Queue<string> queueCopy2 = new
 Queue<string>(array2);

        Console.WriteLine("\nContents of the second copy, with duplicates and
 nulls:");
        foreach( string number in
 queueCopy2 )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nqueueCopy.Contains(\"four\") = {0}",
 
            queueCopy.Contains("four"));

        Console.WriteLine("\nqueueCopy.Clear()");
        queueCopy.Clear();
        Console.WriteLine("\nqueueCopy.Count = {0}", queueCopy.Count);
    }
}

/* This code example produces the following output:

one
two
three
four
five

Dequeuing 'one'
Peek at next item to dequeue: two
Dequeuing 'two'

Contents of the copy:
three
four
five

Contents of the second copy, with duplicates and nulls:



three
four
five

queueCopy.Contains("four") = True

queueCopy.Clear()

queueCopy.Count = 0
 */
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ (ICollection)

指定したコレクションからコピーした要素格納しコピーした要素の数と同じ初期量を備え既定増加率使用する、Queue クラス新しインスタンス初期化します。

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

Public Sub New ( _
    col As ICollection _
)
Dim col As ICollection

Dim instance As New Queue(col)
public Queue (
    ICollection col
)
public:
Queue (
    ICollection^ col
)
public Queue (
    ICollection col
)
public function Queue (
    col : ICollection
)

パラメータ

col

要素コピー元の ICollection。

例外例外
例外種類条件

ArgumentNullException

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

解説解説

Queue容量は、Queue保持できる要素数になりますQueue要素追加すると、必要に応じて、再割り当てを行うことによって容量自動的に増加します。容量を減らすには、TrimToSize を呼び出します。

増加率は、容量増やす必要がある場合に、現在の容量掛け合わせる数値です。増加率Queue生成され時点決定します

要素は、ICollection の IEnumerator によって読み取られる順序と同じ順序で、Queueコピーされます。

このコンストラクタは O(n) 操作です (ncol 内の要素数)。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Queue コンストラクタ


Queue コンストラクタ


Queue ジェネリック クラス

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

オブジェクト先入れ先出しコレクション表します

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

<SerializableAttribute> _
<ComVisibleAttribute(False)> _
Public Class Queue(Of T)
    Implements IEnumerable(Of T), ICollection,
 _
    IEnumerable
[SerializableAttribute] 
[ComVisibleAttribute(false)] 
public class Queue<T> : IEnumerable<T>,
 ICollection, 
    IEnumerable
[SerializableAttribute] 
[ComVisibleAttribute(false)] 
generic<typename T>
public ref class Queue : IEnumerable<T>,
 ICollection, 
    IEnumerable
J# では、ジェネリックな型およびメソッド使用できますが、新規に宣言することはできません。
JScript では、ジェネリックな型およびメソッド使用できません。

型パラメータ

T

キュー内の要素の型を指定します

解説解説
使用例使用例

Queue ジェネリック クラスいくつかのメソッド使用したコード例次に示します。このコード例では、既定容量文字列キュー作成しEnqueue メソッド使用して 5 つ文字列キュー置きますキュー要素列挙されますが、キューの状態は変化しません。Dequeue メソッド使用して最初文字列キューから取り出しますPeek メソッド使用してキュー内の次の項目を調べてから、Dequeue メソッド使用してキューから取り出します

ToArray メソッド使用して配列作成し、その配列キュー要素コピーしてから、IEnumerable を受け取る Queue コンストラクタ配列渡してキューコピー作成しますコピー要素表示されます。

キューの 2 倍のサイズ配列作成されCopyTo メソッド使用して配列中央部で始まる配列要素コピーしますQueue コンストラクタ再度使用して先頭3 つの null 要素を含むキュー2 つ目のコピー作成します

Contains メソッドにより、文字列 "four" がキュー最初コピー含まれていることを示しますその後で、Clear メソッドコピークリアすると、Count プロパティによってキューが空であることが示されます。

Imports System
Imports System.Collections.Generic

Module Example

    Sub Main

        Dim numbers As New
 Queue(Of String)
        numbers.Enqueue("one")
        numbers.Enqueue("two")
        numbers.Enqueue("three")
        numbers.Enqueue("four")
        numbers.Enqueue("five")

        ' A queue can be enumerated without disturbing its contents.
        For Each number As
 String In numbers
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "Dequeuing '{0}'", numbers.Dequeue())
        Console.WriteLine("Peek at next item to dequeue: {0}",
 _
            numbers.Peek())    
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue())

        ' Create a copy of the queue, using the ToArray method and the
        ' constructor that accepts an IEnumerable(Of T).
        Dim queueCopy As New
 Queue(Of String)(numbers.ToArray())

        Console.WriteLine(vbLf & "Contents of the first copy:")
        For Each number As
 String In queueCopy
            Console.WriteLine(number)
        Next
        
        ' Create an array twice the size of the queue, compensating
        ' for the fact that Visual Basic allocates an extra array 
        ' element. Copy the elements of the queue, starting at the
        ' middle of the array. 
        Dim array2((numbers.Count * 2) - 1) As
 String
        numbers.CopyTo(array2, numbers.Count)
        
        ' Create a second queue, using the constructor that accepts
 an
        ' IEnumerable(Of T).
        Dim queueCopy2 As New
 Queue(Of String)(array2)

        Console.WriteLine(vbLf & _
            "Contents of the second copy, with duplicates and
 nulls:")
        For Each number As
 String In queueCopy2
            Console.WriteLine(number)
        Next

        Console.WriteLine(vbLf & "queueCopy.Contains(""four"")
 = {0}", _
            queueCopy.Contains("four"))

        Console.WriteLine(vbLf & "queueCopy.Clear()")
        queueCopy.Clear()
        Console.WriteLine(vbLf & "queueCopy.Count = {0}",
 _
            queueCopy.Count)
    End Sub
End Module

' This code example produces the following output:
'
'one
'two
'three
'four
'five
'
'Dequeuing 'one'
'Peek at next item to dequeue: two
'
'Dequeuing 'two'
'
'Contents of the copy:
'three
'four
'five
'
'Contents of the second copy, with duplicates and nulls:
'
'
'
'three
'four
'five
'
'queueCopy.Contains("four") = True
'
'queueCopy.Clear()
'
'queueCopy.Count = 0
using System;
using System.Collections.Generic;

class Example
{
    public static void Main()
    {
        Queue<string> numbers = new Queue<string>();
        numbers.Enqueue("one");
        numbers.Enqueue("two");
        numbers.Enqueue("three");
        numbers.Enqueue("four");
        numbers.Enqueue("five");

        // A queue can be enumerated without disturbing its contents.
        foreach( string number in
 numbers )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nDequeuing '{0}'", numbers.Dequeue());
        Console.WriteLine("Peek at next item to dequeue: {0}", 
            numbers.Peek());
        Console.WriteLine("Dequeuing '{0}'", numbers.Dequeue());

        // Create a copy of the queue, using the ToArray method and
 the
        // constructor that accepts an IEnumerable<T>.
        Queue<string> queueCopy = new
 Queue<string>(numbers.ToArray());

        Console.WriteLine("\nContents of the first copy:");
        foreach( string number in
 queueCopy )
        {
            Console.WriteLine(number);
        }
        
        // Create an array twice the size of the queue and copy the
        // elements of the queue, starting at the middle of the 
        // array. 
        string[] array2 = new string[numbers.Count
 * 2];
        numbers.CopyTo(array2, numbers.Count);
        
        // Create a second queue, using the constructor that accepts
 an
        // IEnumerable(Of T).
        Queue<string> queueCopy2 = new
 Queue<string>(array2);

        Console.WriteLine("\nContents of the second copy, with duplicates and
 nulls:");
        foreach( string number in
 queueCopy2 )
        {
            Console.WriteLine(number);
        }

        Console.WriteLine("\nqueueCopy.Contains(\"four\") = {0}",
 
            queueCopy.Contains("four"));

        Console.WriteLine("\nqueueCopy.Clear()");
        queueCopy.Clear();
        Console.WriteLine("\nqueueCopy.Count = {0}", queueCopy.Count);
    }
}

/* This code example produces the following output:

one
two
three
four
five

Dequeuing 'one'
Peek at next item to dequeue: two
Dequeuing 'two'

Contents of the copy:
three
four
five

Contents of the second copy, with duplicates and nulls:



three
four
five

queueCopy.Contains("four") = True

queueCopy.Clear()

queueCopy.Count = 0
 */
継承階層継承階層
System.Object
  System.Collections.Generic.Queue
スレッド セーフスレッド セーフ

この型の public static (Visual Basic では Shared) メンバは、スレッド セーフです。すべてのインスタンス メンバスレッド セーフになるかどうか保証されていません。

コレクション変更されない限りQueue では、複数読み込み操作同時に発生して問題ありません。ただし、コレクション列挙処理は、本質的にスレッド セーフな処理ではありません。すべての列挙処理が終わるまでコレクションロックすることにより、列挙処理でのスレッド セーフ確保できますコレクション対し複数スレッドアクセスして読み取り書き込みを行うことができるようにするには、独自に同期化実装する必要があります

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Queue メンバ
System.Collections.Generic 名前空間

Queue プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ SyncRoot Queue へのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

Queue クラス
System.Collections 名前空間
System.Collections.Generic.Queue

Queue プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Count Queue に格納されている要素の数を取得します
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot ICollection へのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

Queue ジェネリック クラス
System.Collections.Generic 名前空間

Queue メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Clear Queue からすべてのオブジェクト削除します
パブリック メソッド Contains ある要素Queue 内に存在するかどうか判断します
パブリック メソッド CopyTo Queue要素既存1 次元Arrayコピーしますコピー操作は、配列内の指定したインデックスから始まります
パブリック メソッド Dequeue Queue先頭にあるオブジェクト削除し返します
パブリック メソッド Enqueue Queue末尾オブジェクト追加します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator Queue反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Peek Queue先頭にあるオブジェクト削除せず返します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド ToArray Queue要素新し配列コピーします
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
パブリック メソッド TrimExcess Queue 内にある実際要素数が現在の容量90% 未満場合は、容量をその数に設定します
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.Generic.IEnumerable<T>.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo ICollection の要素ArrayコピーしますArray特定のインデックスからコピー開始されます。
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション反復処理する列挙子を返します
参照参照

関連項目

Queue ジェネリック クラス
System.Collections.Generic 名前空間

Queue メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Clear Queue からすべてのオブジェクト削除します
パブリック メソッド Clone Queue簡易コピー作成します
パブリック メソッド Contains ある要素Queue 内に存在するかどうか判断します
パブリック メソッド CopyTo Queue要素既存1 次元Arrayコピーしますコピー操作は、配列内の指定したインデックスから始まります
パブリック メソッド Dequeue Queue先頭にあるオブジェクト削除し返します
パブリック メソッド Enqueue Queue末尾オブジェクト追加します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 ( Object から継承されます。)
パブリック メソッド GetEnumerator Queue反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 ( Object から継承されます。)
パブリック メソッド Peek Queue先頭にあるオブジェクト削除せず返します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 ( Object から継承されます。)
パブリック メソッド Synchronized 同期されている (スレッド セーフな) Queue ラッパー返します
パブリック メソッド ToArray Queue要素新し配列コピーします
パブリック メソッド ToString  現在の Object を表す String返します。 ( Object から継承されます。)
パブリック メソッド TrimToSize 容量Queue 内にある実際要素数に設定します
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Queue クラス
System.Collections 名前空間
System.Collections.Generic.Queue

Queue メンバ

オブジェクト先入れ先出しコレクション表します

Queue ジェネリック型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Count Queue格納されている要素の数を取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Clear Queue からすべてのオブジェクト削除します
パブリック メソッド Contains ある要素Queue 内に存在するかどうか判断します
パブリック メソッド CopyTo Queue要素既存1 次元Arrayコピーしますコピー操作は、配列内の指定したインデックスから始まります
パブリック メソッド Dequeue Queue先頭にあるオブジェクト削除し返します
パブリック メソッド Enqueue Queue末尾オブジェクト追加します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator Queue反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Peek Queue先頭にあるオブジェクト削除せず返します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド ToArray Queue要素新し配列コピーします
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
パブリック メソッド TrimExcess Queue 内にある実際要素数が現在の容量90% 未満場合は、容量をその数に設定します
プロテクト メソッドプロテクト メソッド
明示的インターフェイスの実装明示的インターフェイス実装
  名前 説明
インターフェイスの明示的な実装 System.Collections.Generic.IEnumerable<T>.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.ICollection.CopyTo ICollection の要素ArrayコピーしますArray特定のインデックスからコピー開始されます。
インターフェイスの明示的な実装 System.Collections.IEnumerable.GetEnumerator コレクション反復処理する列挙子を返します
インターフェイスの明示的な実装 System.Collections.ICollection.SyncRoot ICollection へのアクセス同期するために使用できるオブジェクト取得します
参照参照

関連項目

Queue ジェネリック クラス
System.Collections.Generic 名前空間

Queue メンバ

オブジェクト先入れ先出しコレクション表します

Queue データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ SyncRoot Queue へのアクセス同期するために使用できるオブジェクト取得します
パブリック メソッドパブリック メソッド
( プロテクト メソッド参照)
  名前 説明
パブリック メソッド Clear Queue からすべてのオブジェクト削除します
パブリック メソッド Clone Queue簡易コピー作成します
パブリック メソッド Contains ある要素Queue 内に存在するかどうか判断します
パブリック メソッド CopyTo Queue要素既存1 次元Arrayコピーしますコピー操作は、配列内の指定したインデックスから始まります
パブリック メソッド Dequeue Queue先頭にあるオブジェクト削除し返します
パブリック メソッド Enqueue Queue末尾オブジェクト追加します
パブリック メソッド Equals  オーバーロードされます2 つObject インスタンス等しかどうか判断します。 (Object から継承されます。)
パブリック メソッド GetEnumerator Queue反復処理する列挙子を返します
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用適してます。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスType取得します。 (Object から継承されます。)
パブリック メソッド Peek Queue先頭にあるオブジェクト削除せず返します
パブリック メソッド ReferenceEquals  指定した複数Object インスタンス同一かどうか判断します。 (Object から継承されます。)
パブリック メソッド Synchronized 同期されている (スレッド セーフな) Queue ラッパー返します
パブリック メソッド ToArray Queue要素新し配列コピーします
パブリック メソッド ToString  現在の Object を表す String返します。 (Object から継承されます。)
パブリック メソッド TrimToSize 容量Queue 内にある実際要素数に設定します
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Queue クラス
System.Collections 名前空間
System.Collections.Generic.Queue

待ち行列

(queue から転送)

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/06/28 09:39 UTC 版)

待ち行列(まちぎょうれつ、: queue




「待ち行列」の続きの解説一覧

queue

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2019/04/29 13:43 UTC 版)

Standard Template Library」の記事における「queue」の解説

キュー。(FIFO; First In, First Out)

※この「queue」の解説は、「Standard Template Library」の解説の一部です。
「queue」を含む「Standard Template Library」の記事については、「Standard Template Library」の概要を参照ください。


queue

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/06/27 00:18 UTC 版)

行列 (曖昧さ回避)」の記事における「queue」の解説

あるサービスの提供を受けるために待っている人の行列のこと。待ち行列理論 計算機科学でのデータ構造一種キュー (コンピュータ) 道路交通法における行列歩行者参照

※この「queue」の解説は、「行列 (曖昧さ回避)」の解説の一部です。
「queue」を含む「行列 (曖昧さ回避)」の記事については、「行列 (曖昧さ回避)」の概要を参照ください。


queue

出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2022/06/26 23:47 UTC 版)

キュー」の記事における「queue」の解説

何かを待つために人々一筋集団作った状態。→列、行列 (曖昧さ回避)計算工学待ち行列上記概念転用で、データジョブ並んでいる状態で、先に入ったものが先に出るしくみのもののこと。→ キュー (コンピュータ)待ち行列理論 このページ曖昧さ回避のためのページです。一つ語句複数の意味職能有する場合水先案内のために、異な用法を一覧にしてあります。お探しの用語に一番近い記事選んで下さい。このページリンクしているページ見つけたら、リンクを適切な項目に張り替え下さい

※この「queue」の解説は、「キュー」の解説の一部です。
「queue」を含む「キュー」の記事については、「キュー」の概要を参照ください。

ウィキペディア小見出し辞書の「queue」の項目はプログラムで機械的に意味や本文を生成しているため、不適切な項目が含まれていることもあります。ご了承くださいませ。 お問い合わせ


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

辞書ショートカット

すべての辞書の索引

「queue」の関連用語

queueのお隣キーワード
検索ランキング

   

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



queueのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
実用日本語表現辞典実用日本語表現辞典
Copyright © 2024実用日本語表現辞典 All Rights Reserved.
デジタル大辞泉デジタル大辞泉
(C)Shogakukan Inc.
株式会社 小学館
テレマーケティングジャパンテレマーケティングジャパン
Copyright (C)TELEMARKETING JAPAN, INC
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.
日本オペレーションズ・リサーチ学会日本オペレーションズ・リサーチ学会
Copyright (C) 2024 (社)日本オペレーションズ・リサーチ学会 All rights reserved.
ウィキペディアウィキペディア
All text is available under the terms of the GNU Free Documentation License.
この記事は、ウィキペディアの待ち行列 (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。 Weblio辞書に掲載されているウィキペディアの記事も、全てGNU Free Documentation Licenseの元に提供されております。
ウィキペディアウィキペディア
Text is available under GNU Free Documentation License (GFDL).
Weblio辞書に掲載されている「ウィキペディア小見出し辞書」の記事は、WikipediaのStandard Template Library (改訂履歴)、行列 (曖昧さ回避) (改訂履歴)、キュー (改訂履歴)の記事を複製、再配布したものにあたり、GNU Free Documentation Licenseというライセンスの下で提供されています。

©2024 GRAS Group, Inc.RSS