-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
afe7d7a
commit 602741c
Showing
1 changed file
with
29 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
.pragma library | ||
|
||
// A simple stack function that mimics/replicates QStack | ||
function Stack() { | ||
var stack = []; | ||
|
||
this.clear = function() { | ||
stack = []; | ||
} | ||
|
||
this.push = function(element) { | ||
stack.push(element); | ||
}; | ||
|
||
this.pop = function() { | ||
stack.pop(); | ||
}; | ||
|
||
this.size = function() { | ||
return stack.length; | ||
} | ||
|
||
this.top = function() { | ||
if (stack.length > 0) { | ||
return stack[stack.length - 1]; | ||
} | ||
return undefined; | ||
} | ||
} |