public static void copyElements(Utils.Stack <Student> src, Utils.Stack <Student> dest) { Utils.Stack <Student> aux = new Utils.Stack <Student>(); while (!src.isEmpty()) { try { aux.push(src.pop()); } catch (MyException e) { Console.WriteLine(e.Message); } } while (!aux.isEmpty()) { try { dest.push(aux.pop()); } catch (MyException e) { Console.WriteLine(e.Message); } } }
public RepositoryStack() { //Stack repository constructor //Preconditions: //Postcond: A new empty repository stack object is build studentlist = new Utils.Stack <T>(); }
public bool IsPalinDrome(SinglyLinkedListNode <string> node) { SinglyLinkedListNode <string> slow = node; SinglyLinkedListNode <string> fast = node; var buffer = new Utils.Stack <string>(); while (fast != null && fast.Next != null) { buffer.Push(slow.Data); slow = slow.Next; fast = fast.Next.Next; } if (fast != null && fast.Next != null) { slow = slow.Next; } while (slow != null) { if (buffer.Peek() == slow.Data) { buffer.Pop(); } slow = slow.Next; } return(buffer.IsEmpty()); }
public List <T> toArray() { List <T> crepo = new List <T>(); Utils.Stack <T> stackcopy = this.getAll(); int i = 0; while (!stackcopy.isEmpty()) { crepo.Add(stackcopy.pop()); } return(crepo); }
public void removeStudent(Object s) { Utils.Stack <T> aux = new Utils.Stack <T>(); while (true) { T ss = this.studentlist.pop(); if (ss.Equals(s)) { break; } aux.push(ss); } while (aux.getSize() != 0) { this.studentlist.push(aux.pop()); } }