Skip to content

Instantly share code, notes, and snippets.

@LittleHelicase
Created November 7, 2014 08:13
Show Gist options
  • Save LittleHelicase/b9cfb22fb399fc32fc32 to your computer and use it in GitHub Desktop.
Save LittleHelicase/b9cfb22fb399fc32fc32 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>DuA Stack Implementierung</title>
<!-- der Stack wird über die ArrayList implementiert -->
<script src="http://jsbin.com/cuqure.js"></script>
</head>
<body>
<script id="jsbin-javascript">
function ArrayStack(){
this.arrayList = null;
this.create = function(){
this.arrayList = new ArrayList();
this.arrayList.create();
};
this.empty = function(){
return (this.arrayList.length() === 0);
};
this.pop = function(){
var val = this.top();
this.arrayList.deletePos(this.arrayList.last());
return val;
};
this.top = function(){
return this.arrayList.retrieve(this.arrayList.last());
}
this.push = function(x){
this.arrayList.insert(this.arrayList.last(),x);
}
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">function ArrayStack(){
this.arrayList = null;
this.create = function(){
this.arrayList = new ArrayList();
this.arrayList.create();
};
this.empty = function(){
return (this.arrayList.length() === 0);
};
this.pop = function(){
var val = this.top();
this.arrayList.deletePos(this.arrayList.last());
return val;
};
this.top = function(){
return this.arrayList.retrieve(this.arrayList.last());
}
this.push = function(x){
this.arrayList.insert(this.arrayList.last(),x);
}
}</script></body>
</html>
function ArrayStack(){
this.arrayList = null;
this.create = function(){
this.arrayList = new ArrayList();
this.arrayList.create();
};
this.empty = function(){
return (this.arrayList.length() === 0);
};
this.pop = function(){
var val = this.top();
this.arrayList.deletePos(this.arrayList.last());
return val;
};
this.top = function(){
return this.arrayList.retrieve(this.arrayList.last());
}
this.push = function(x){
this.arrayList.insert(this.arrayList.last(),x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment