本文整理汇总了C#中Stack.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C# Stack.isEmpty方法的具体用法?C# Stack.isEmpty怎么用?C# Stack.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stack
的用法示例。
在下文中一共展示了Stack.isEmpty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
// Print the top M lines in the input stream.
Console.Write("Write Lenth : ");
int M = int.Parse(Console.ReadLine());
Console.Write("Write Del max(True) or min(False) : ");
bool b = false;
bool.TryParse(Console.ReadLine(),out b);
PriorityQueue<int> pq = new PriorityQueue<int>(M,b);
Console.WriteLine("Insert Queue : ");
for(int i=0;i<M;i++)
pq.Insert(int.Parse(Console.ReadLine()));
Stack<int> stack = new Stack<int>();
while (!pq.isEmpty())
stack.push(pq.Del());
Console.WriteLine("\n\t OutPut Stack");
while(!stack.isEmpty())
Console.WriteLine(stack.pull());
Console.ReadKey();
}
示例2: Sort
//O(n^2) time, O(n) space
static Stack<int> Sort(Stack<int> stack)
{
Stack<int> stack2 = new Stack<int>();
while (!stack.isEmpty()) {
int temp = stack.pop();
while ((!stack2.isEmpty()) && (temp < stack2.peek()))
{
stack.push(stack2.pop());
}
stack2.push(temp);
}
while (!stack2.isEmpty())
stack.push(stack2.pop());
return stack;
}
示例3: Main
public static void Main(string[] args)
{
Stack<int> st = new Stack<int>(3);
for (int i = 0; i < 10; i++)
st.push(i);
while (!st.isEmpty())
{
Console.WriteLine(st.pop());
}
}
示例4: Main
static void Main(string[] args)
{
Stack<int> stack = new Stack<int>();
stack.push(5);
stack.push(3);
stack.push(2);
stack.push(6);
stack.push(7);
stack = Sort(stack);
while (!stack.isEmpty()) {
Console.WriteLine(stack.pop());
}
}
示例5: iterativeDF
public void iterativeDF(int s)
{
Stack S = new Stack();
id = 0;
for (int v = 1; v < V + 1; ++v)
{
visited[v] = 0;
}
S.push(s);
int prev = 0;
while (!S.isEmpty())
{
int v = S.pop();
if (visited[v] == 0)
{
visited[v] = ++id;
Console.WriteLine("Visited vertex {0} along edge {1} - {0}", v, prev);
Node cur = adj[v];
while (cur != z)
{
int u = cur.vert;
if (visited[u] == 0)
{
S.push(u);
}
prev = v;
cur = cur.next;
}
}
}
}