System::Collections::Generic::Queue 클래스

Queue class

Queue class forward declaration.

template<typename T>class Queue : public System::Collections::Generic::IEnumerable<T>
매개변수설명
T요소 타입.

Nested classes

메서드

메서드설명
virtual Clear()큐의 모든 요소를 삭제합니다.
virtual Contains(const T&) constoperator == 를 사용하여 요소를 비교함으로써 큐에 특정 요소가 포함되어 있는지 확인합니다.
data()기본 데이터 구조 접근자입니다.
data() const기본 데이터 구조 접근자입니다.
Dequeue()큐의 앞에서 항목을 가져옵니다.
Enqueue(const T&)항목을 큐의 끝에 삽입합니다.
virtual get_Count() const큐의 요소 개수를 가져옵니다.
GetEnumerator() override큐를 순회하기 위한 열거자를 가져옵니다.
Peek()큐의 앞에서 항목을 가져오지만 큐에서 제거하지는 않습니다.
Queue()빈 큐를 생성합니다.
Queue(int)빈 큐를 생성합니다.
Queue(const SharedPtr<IEnumerable<T>>&)복사 생성자.
virtualizeBeginConstIterator() const override현재 컨테이너에 대한 begin const iterator 구현을 가져옵니다.
virtualizeBeginIterator() override현재 컨테이너에 대한 begin iterator 구현을 가져옵니다.
virtualizeEndConstIterator() const override현재 컨테이너에 대한 end const iterator 구현을 가져옵니다.
virtualizeEndIterator() override현재 컨테이너에 대한 end iterator 구현을 가져옵니다.

Typedefs

타입 정의설명
IEnumerablePtr동일한 유형 요소들의 컨테이너입니다.
IEnumeratorPtrEnumerator 유형.
queue_tRTTI 정보.
ValueType이 유형.

비고

Queue container wrapping STL list. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

#include <system/collections/queue.h>
#include <system/smart_ptr.h>

using namespace System;
using namespace System::Collections::Generic;

void PrintItems(const SmartPtr<IEnumerable<int>> &queue)
{
  for (const int item: queue)
  {
    std::cout << item << ' ';
  }
  std::cout << std::endl;
}

int main()
{
  // Queue 클래스 인스턴스를 생성합니다.
  auto queue = MakeObject<Queue<int>>();

  // 큐를 채웁니다.
  queue->Enqueue(1);
  queue->Enqueue(2);
  queue->Enqueue(3);

  // 첫 번째 큐 항목을 출력합니다. Peek 메서드는 큐에서 항목을 제거하지 않습니다.
  std::cout << queue->Peek() << std::endl;
  // 큐 항목들을 출력합니다.
  PrintItems(queue);

  // 첫 번째 큐 항목을 출력합니다. Dequeue 메서드는 큐에서 항목을 제거합니다.
  std::cout << queue->Dequeue() << std::endl;
  // 큐 항목들을 출력합니다.
  PrintItems(queue);

  return 0;
}
/*
This code example produces the following output:
1
1 2 3
1
2 3
*/

또 보기