adding cs235

This commit is contained in:
dm
2016-04-06 20:46:10 -07:00
parent 8e52ce1982
commit cf99ec6565
178 changed files with 13079 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#include "stack.h"
bool stack::addToStack(int id) {
if(in_stack(id)) {
return false;
}
l.insertHead(id);
return true;
}
int stack::removeFromStack() {
int id = l.at(0);
l.remove(id);
return false;
}
int stack::showTopOfStack() {
if(l.size() == 0)
return -1;
int top = l.at(0);
return top;
}
int stack::showSizeOfStack() {
return l.size();
}
bool stack::in_stack(int id) {
node* node_ptr = l.head;
while(node_ptr != NULL) {
if(node_ptr->id == id) {
return true;
}
node_ptr = node_ptr->next;
}
return false;
}