Revision: 63601
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 21, 2013 18:17 by zaxbbun
Initial Code
class Queue: def __init__(self): self.stack_a = Stack() self.stack_b = Stack() def EnQueue(self, data): self.statck_a.Push(data) def DeQueue(self): if self.stack_b.IsEmpty(): self.stack_a.Lock() for data in self.stack_a: self.stack_b.Push(data) self.stack_a.UnLock() return self.stack_b.Pop() class Stack: def __init__(self): self.queue_a = Queue() self.queue_b = Queue() def Push(self, data): self.queue_a.EnQueue(data) def Pop(self): if self.queue_b.IsEmpty(): self.queue_a.Lock() for i in range(self.queue_b.Length()): self.queue_b.EnQueue(self.queue_a.GetHead()) self.queue_b.UnLock() return self.queue_b.GetTail()
Initial URL
Initial Description
conversion between queue and stack
Initial Title
conversion between queue and stack
Initial Tags
Initial Language
C