-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jade Meskill and Roy van de Water
authored and
Roy van de Water
committed
Dec 9, 2013
1 parent
aa1c25e
commit ad40258
Showing
7 changed files
with
113 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,56 @@ | ||
#ifndef _CHAR_QUEUE | ||
#define _CHAR_QUEUE | ||
|
||
#include <string> | ||
#include "char.h" | ||
|
||
class CharQueue { | ||
private: | ||
int mSize; | ||
// Char *head; | ||
Char *mHead; | ||
Char *mTail; | ||
|
||
public: | ||
CharQueue() { | ||
mSize = 0; | ||
mHead = new Char(); | ||
mTail = mHead; | ||
} | ||
|
||
int size() { | ||
return mSize; | ||
void clear() { | ||
mSize = 0; | ||
mHead = new Char(); | ||
mTail = mHead; | ||
} | ||
|
||
void pop() { | ||
// char character = head->get_character(); | ||
// head = head->get_next(); | ||
// mSize--; | ||
mSize--; | ||
// return character; | ||
char pop() { | ||
Char *realHead = mHead->get_next(); | ||
char character = '\0'; | ||
|
||
if(realHead) { | ||
character = realHead->get_character(); | ||
mHead->set_next(realHead->get_next()); | ||
mSize--; | ||
} | ||
|
||
return character; | ||
} | ||
|
||
void push(char character) { | ||
// Char *next = new Char(character); | ||
// Char *current = head; | ||
// while (mSize > 0 && !current->last()) { | ||
// current = current->get_next(); | ||
// } | ||
// current->set_next(next); | ||
Char *next = new Char(character); | ||
mTail->set_next(next); | ||
mTail = next; | ||
|
||
mSize++; | ||
} | ||
|
||
int size() { | ||
return mSize; | ||
} | ||
|
||
std::string to_string() { | ||
return ""; | ||
} | ||
}; | ||
|
||
#endif /* _CHAR_QUEUE */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
g++ -o run_all run_all.cpp | ||
|
||
test: all | ||
./run_all |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.