stack::empty (STL/CLR)
測試是否沒有項目呈現。
bool empty();
備註
成員函式會傳回空白的受控制序列的則為 true。 它相當於stack::size (STL/CLR)() == 0。 您可以用它來測試是否堆疊是空的。
範例
// cliext_stack_empty.cpp
// compile with: /clr
#include <cliext/stack>
typedef cliext::stack<wchar_t> Mystack;
int main()
{
Mystack c1;
c1.push(L'a');
c1.push(L'b');
c1.push(L'c');
// display initial contents " a b c"
for each (wchar_t elem in c1.get_container())
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
System::Console::WriteLine("size() = {0}", c1.size());
System::Console::WriteLine("empty() = {0}", c1.empty());
// clear the container and reinspect
c1.pop();
c1.pop();
c1.pop();
System::Console::WriteLine("size() = {0}", c1.size());
System::Console::WriteLine("empty() = {0}", c1.empty());
return (0);
}
需求
標頭: < cliext/堆疊 >
Namespace: cliext