Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleanup

  • Loading branch information...
commit 3ac227d15b9b76adf1e9c78ffd295b32d70ee980 1 parent d0db4d7
@nzakas authored
View
1  .gitignore
@@ -0,0 +1 @@
+holding/
View
48 data-structures/DequeExample.htm
@@ -1,48 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <title>Deque Example</title>
- <script language="javascript" type="text/javascript" src="doublelinkedlist.js"></script>
- <script language="javascript" type="text/javascript" src="deque.js"></script>
-</head>
-<body>
- <h2>Deque Example</h2>
- <hr />
- <script>
-
-//test creating the Deque
-var oDeque = new Deque;
-
-//test the putFront() method
-oDeque.putFront("red");
-oDeque.putFront("orange");
-
-//test the toString() method
-document.write("<p><b>Original Deque: </b><br />" + oDeque + "</p>");
-
-//test the putBack() method
-oDeque.putBack("yellow");
-document.write("<p><b>Deque after adding to back: </b><br />" + oDeque + "</p>");
-
-//test the getFront() method
-var vItem = oDeque.getFront();
-document.write("<p><b>Deque after getting first item: </b><br />" + oDeque + "<br /><b>Removed Item from Front: </b><br />" + vItem + "</p>");
-
-//test the getBack() method
-var vItem = oDeque.getBack();
-document.write("<p><b>Deque after getting last item: </b><br />" + oDeque + "<br /><b>Removed Item from Back: </b><br />" + vItem + "</p>");
-
-//test the isEmpty() method
-document.write("<p><b>Is Deque empty?: </b><br />" + oDeque.isEmpty() + "</p>");
-
-//test the getFront() method
-var vItem3 = oDeque.getFront();
-document.write("<p><b>Deque after getting first item: </b><br />" + oDeque + "<br /><b>Removed Item from Front: </b><br />" + vItem3 + "</p>");
-
-//test the isEmpty() method
-document.write("<p><b>Is Deque empty?: </b><br />" + oDeque.isEmpty() + "</p>");
-
- </script>
- </body>
-</html>
View
45 data-structures/QueueExample.htm
@@ -1,45 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <title>Queue Example</title>
- <script language="javascript" type="text/javascript" src="linkedlist.js"></script>
- <script language="javascript" type="text/javascript" src="queue.js"></script>
-</head>
-<body>
- <h2>Queue Example</h2>
- <hr />
- <script>
-
-//test creating the queue
-var oQueue = new Queue;
-
-//test the put() method
-oQueue.put("red");
-oQueue.put("orange");
-oQueue.put("yellow");
-
-//test the toString() method
-document.write("<p><b>Original Queue: </b><br />" + oQueue + "</p>");
-
-//test the get() method
-var vItem = oQueue.get();
-document.write("<p><b>Queue after getting first item: </b><br />" + oQueue + "<br /><b>Removed Item: </b><br />" + vItem + "</p>");
-
-//test the get() method
-var vItem2 = oQueue.get();
-document.write("<p><b>Queue after getting first item: </b><br />" + oQueue + "<br /><b>Removed Item: </b><br />" + vItem2 + "</p>");
-
-//test the isEmpty() method
-document.write("<p><b>Is Queue empty?: </b><br />" + oQueue.isEmpty() + "</p>");
-
-//test the get() method
-var vItem3 = oQueue.get();
-document.write("<p><b>Queue after getting first item: </b><br />" + oQueue + "<br /><b>Removed Item: </b><br />" + vItem3 + "</p>");
-
-//test the isEmpty() method
-document.write("<p><b>Is Queue empty?: </b><br />" + oQueue.isEmpty() + "</p>");
-
- </script>
- </body>
-</html>
View
38 data-structures/StackExample.htm
@@ -1,38 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <title>Stack Example</title>
- <script language="javascript" type="text/javascript" src="linkedlist.js"></script>
- <script language="javascript" type="text/javascript" src="stack.js"></script>
-</head>
-<body>
- <h2>Stack Example</h2>
- <hr />
- <script>
-
-//test creating the stack
-var oStack = new Stack;
-
-//test the push() method
-oStack.push("red");
-oStack.push("orange");
-oStack.push("yellow");
-
-//test the toString() method
-document.write("<p><b>Original Stack: </b><br />" + oStack + "</p>");
-
-//test the pop() method
-var vItem = oStack.pop();
-document.write("<p><b>Stack after popping: </b><br />" + oStack + "<br /><b>Popped Item: </b><br />" + vItem + "</p>");
-
-//test the isEmpty() method
-document.write("<p><b>Is Stack empty?: </b><br />" + oStack.isEmpty() + "</p>");
-oStack.pop();
-oStack.pop();
-document.write("<p><b>Stack after popping two more items: </b><br />" + oStack + "</p>");
-document.write("<p><b>Is Stack empty?: </b><br />" + oStack.isEmpty() + "</p>");
-
- </script>
- </body>
-</html>
View
160 data-structures/deque.js
@@ -1,160 +0,0 @@
-//-----------------------------------------------------------------
-// Class Deque
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// A classic Deque interface.
-//-----------------------------------------------------------------
-function Deque() {
- this.items = new DoubleLinkedList
-}
-
-//-----------------------------------------------------------------
-// Method Deque.getBack()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method gets off the back item in the Deque and returns it.
-//
-// Arguments
-// (none)
-//
-// Returns
-// The back item.
-//-----------------------------------------------------------------
-Deque.prototype.getBack = function() {
-
- var vItem = null;
-
- if (!this.isEmpty()) {
-
- vItem = this.items.item(this.items.length - 1);
-
- this.items.remove(this.items.length - 1);
- }
-
- return vItem;
-}
-
-
-//-----------------------------------------------------------------
-// Method Deque.getFront()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method gets the first item in the Deque and returns it.
-//
-// Arguments
-// (none)
-//
-// Returns
-// The first item.
-//-----------------------------------------------------------------
-Deque.prototype.getFront = function() {
-
- var vItem = null;
-
- if (!this.isEmpty()) {
-
- vItem = this.items.item(0);
-
- this.items.remove(0);
- }
-
- return vItem;
-}
-
-//-----------------------------------------------------------------
-// Method Deque.isEmpty()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method determines if the Deque is empty.
-//
-// Arguments
-// (none)
-//
-// Returns
-// True if the Deque is empty, false if not.
-//-----------------------------------------------------------------
-Deque.prototype.isEmpty = function() {
- return this.items.length == 0;
-}
-
-//-----------------------------------------------------------------
-// Method Deque.putBack()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method puts the given argument at the back of the Deque.
-//
-// Arguments
-// vItem (variant) - the object to put into the Deque.
-//
-// Returns
-// (nothing)
-//-----------------------------------------------------------------
-Deque.prototype.putBack = function (vItem) {
- this.items.add(vItem);
- return vItem;
-}
-
-//-----------------------------------------------------------------
-// Method Deque.putFront()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method puts the given argument at the front of the Deque.
-//
-// Arguments
-// oElement (Object) - the object to put into the Deque.
-//
-// Returns
-// (nothing)
-//-----------------------------------------------------------------
-Deque.prototype.putFront = function (vData) {
- var oNode = new DoubleLinkedListNode(vData);
-
- if (this.isEmpty()) {
- this.items.__first__ = oNode;
- this.items.__last__ = oNode;
- } else {
- var oPtr = this.items.__first__;
- this.items.__first__ = oNode;
- oNode.next = oPtr;
- oPtr.prev = oNode;
- }
-
- this.items.length++;
-}
-
-//-----------------------------------------------------------------
-// Method Deque.toString()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method returns the contents of the Deque as a string.
-//
-// Arguments
-// (none)
-//
-// Returns
-// A String representing the contents of the Deque.
-//-----------------------------------------------------------------
-Deque.prototype.toString = function() {
- return this.items.toString();
-}
View
101 data-structures/queue.js
@@ -1,101 +0,0 @@
-//-----------------------------------------------------------------
-// Class Queue
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// A classic Queue interface.
-//-----------------------------------------------------------------
-function Queue() {
- this.items = new LinkedList;
-}
-
-//-----------------------------------------------------------------
-// Method Queue.get()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method gets the first item in the Queue and returns it.
-//
-// Arguments
-// (none)
-//
-// Returns
-// The first item.
-//-----------------------------------------------------------------
-Queue.prototype.get = function() {
-
- var vItem = null;
-
- if (!this.isEmpty()) {
-
- vItem = this.items.item(0);
-
- this.items.remove(0);
- }
-
- return vItem;
-}
-
-//-----------------------------------------------------------------
-// Method Queue.isEmpty()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method determines if the Queue is empty.
-//
-// Arguments
-// (none)
-//
-// Returns
-// True if the Queue is empty, false if not.
-//-----------------------------------------------------------------
-Queue.prototype.isEmpty = function() {
- return this.items.length == 0;
-}
-
-
-
-//-----------------------------------------------------------------
-// Method Queue.put()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method puts the given arguments at the end of the Queue.
-//
-// Arguments
-// vItem (variant) - the object to put into the Queue.
-//
-// Returns
-// (nothing)
-//-----------------------------------------------------------------
-Queue.prototype.put = function (vItem) {
- this.items.add(vItem);
- return vItem;
-}
-
-//-----------------------------------------------------------------
-// Method Queue.toString()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 9/5/02
-//
-// Description
-// This method returns the contents of the queue as a string.
-//
-// Arguments
-// (none)
-//
-// Returns
-// A String representing the contents of the queue.
-//-----------------------------------------------------------------
-Queue.prototype.toString = function() {
- return this.items.toString();
-}
View
103 data-structures/stack.js
@@ -1,103 +0,0 @@
-//-----------------------------------------------------------------
-// Class Stack
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 6/3/02
-//
-// Description
-// A classic stack interface.
-//
-// Arguments
-// Any number of parameters to be pushed onto the stack.
-//-----------------------------------------------------------------
-function Stack() {
- this.items = new LinkedList;
-}
-
-//-----------------------------------------------------------------
-// Method Stack.isEmpty()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 6/3/02
-//
-// Description
-// This method determines if the stack is empty.
-//
-// Parameters
-// (none)
-//
-// Returns
-// True if the stack is empty, false if not.
-//-----------------------------------------------------------------
-Stack.prototype.isEmpty = function() {
- return this.items.length == 0;
-}
-
-//-----------------------------------------------------------------
-// Method Stack.pop()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 6/3/02
-//
-// Description
-// This method pops off the top item in the stack and returns it.
-//
-// Parameters
-// (none)
-//
-// Returns
-// The popped item.
-//-----------------------------------------------------------------
-Stack.prototype.pop = function() {
-
- var vItem = null;
-
- if (!this.isEmpty()) {
-
- vItem = this.items.item(this.items.length - 1);
-
- this.items.remove(this.items.length - 1);
- }
-
- return vItem;
-}
-
-
-//-----------------------------------------------------------------
-// Method Stack.push()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 6/3/02
-//
-// Description
-// This method pushes the given arguments onto the top of the stack.
-//
-// Parameters
-// vItem (variant) - the object to push onto the stack.
-//
-// Returns
-// (nothing)
-//-----------------------------------------------------------------
-Stack.prototype.push = function(vItem) {
- this.items.add(vItem);
- return vItem;
-}
-
-//-----------------------------------------------------------------
-// Method Stack.toString()
-//-----------------------------------------------------------------
-// Author(s)
-// Nicholas C. Zakas (NCZ), 6/3/02
-//
-// Description
-// This method returns the contents of the stack as a string.
-//
-// Parameters
-// (none)
-//
-// Returns
-// A String representing the contents of the stack.
-//-----------------------------------------------------------------
-Stack.prototype.toString = function() {
- return this.items.toString();
-}
Please sign in to comment.
Something went wrong with that request. Please try again.