System::Collections::Generic::Stack क्लास

Stack class

Stack class forward declaration.

template<typename T>class Stack : public System::Collections::Generic::IEnumerable<T>
पैरामीटरविवरण
Tतत्व प्रकार।

Nested classes

विधियाँ

विधिविवरण
AddRange(IEnumerablePtr)तत्वों को स्टैक में रखता है।
virtual Clear()स्टैक से सभी तत्वों को हटाता है।
virtual Contains(const T&) constजाँचता है कि विशिष्ट आइटम कंटेनर में मौजूद है या नहीं; तुलना के लिए ऑपरेटर == का उपयोग करता है।
data()आंतरिक डेटा संरचना अभिगमकर्ता।
data() constआंतरिक डेटा संरचना अभिगमकर्ता।
virtual get_Count() constस्टैक में तत्वों की संख्या प्राप्त करता है।
GetEnumerator() overrideवर्तमान स्टैक के माध्यम से इटररेट करने के लिए एन्यूमरेटर प्राप्त करता है।
Peek()स्टैक के शीर्ष से तत्व प्राप्त करता है, लेकिन उसे स्टैक में रखता है।
Pop()स्टैक के शीर्ष से तत्व प्राप्त करता है।
Push(const T&)स्टैक के शीर्ष पर तत्व रखता है।
Stack()खाली स्टैक बनाता है।
Stack(int)खाली स्टैक बनाता है।
Stack(IEnumerablePtr)कॉपी कंस्ट्रक्टर।
virtual ToArray()स्टैक को एरे में परिवर्तित करता है।
virtualizeBeginConstIterator() const overrideवर्तमान कंटेनर के लिए begin const इटररेटर का कार्यान्वयन प्राप्त करता है।
virtualizeBeginIterator() overrideवर्तमान कंटेनर के लिए begin इटररेटर का कार्यान्वयन प्राप्त करता है।
virtualizeEndConstIterator() const overrideवर्तमान कंटेनर के लिए end const इटररेटर का कार्यान्वयन प्राप्त करता है।
virtualizeEndIterator() overrideवर्तमान कंटेनर के लिए end इटररेटर का कार्यान्वयन प्राप्त करता है।

Typedefs

टाइपडिफ़विवरण
IEnumerablePtrएक ही प्रकार के तत्वों को शामिल करने वाला संग्रह।
IEnumeratorPtrEnumerator प्रकार।
stack_tRTTI जानकारी।
ValueTypeवैल्यू टाइप।

टिप्पणियाँ

Stack class wrapping std::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/stack.h>
#include <system/smart_ptr.h>

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

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

int main()
{
  // Stack-क्लास का इंस्टेंस बनाएं।
  auto stack = MakeObject<Stack<int>>();

  // स्टैक को भरें।
  stack->Push(1);
  stack->Push(2);
  stack->Push(3);

  // स्टैक का अंतिम आइटम प्रिंट करें। Peek मेथड स्टैक से कोई आइटम नहीं हटाता है।
  std::cout << stack->Peek() << std::endl;
  PrintItems(stack);

  // स्टैक का अंतिम आइटम प्रिंट करें। Pop मेथड स्टैक से एक आइटम हटाता है।
  std::cout << stack->Pop() << std::endl;
  PrintItems(stack);

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

संबंधित देखें