<textarea id="text" rows="10" cols="50">"A C program is like a fast dance on a newly waxed dance floor by people carrying razors."
- Waldi Ravens.</textarea>
<br/>
<input type="button" value="Hash Phrase" onClick="beginHash();"/>
<br/>
<div id="output"/>
JavaScript
// Class Definitions
function Node(id, content, last)
{
this.id = id;
this.next = null;
this.last = last;
this.content = content;
this.toString = function()
{
return content;
}
this.clone = function()
{
var newNode = new Node(this.id, this.content, this.last);
newNode.next = this.next;
return newNode;
}
}
function List()
{
this.head = null;
this.length = 0;
this.append = function(content)
{
// Go to end of list if length is not 0
if (this.head != null)
{
this.goto_end();
}
// Create new node
var node = new Node(this.length, content, null);
// Check if new node is first node
if (this.head != null)
{
node.last = this.head;
this.head.next = node;
}
// Add index operator
this[this.length] = node;
// Update list properties
this.head = node;
this.length++;
}
this.goto_begin = function()
{
// Reset head to beginning of list
while (this.previous()) {}
}
this.goto_end = function()
{
// Traverse list until next is null
while (this.next()) {}
}
this.previous = function()
{
if (this.head.last != null)
{
this.head = this.head.last;
return true;
}
else
{
return false;
}
}
this.next = function()
{
if (this.head.next != null)
{
this.head = this.head.next;
return true;
}
else
{
return false;
}
}
this.clear = function()
{
this.head = null;
this.length = 0;
// Remove all node properties
for(var prop in this)
{
if(this[prop] instanceof Node) {
delete this[prop]
}
}
}
this.indexOf = function(value)
{
if(this.length != 0)
{
for(var prop in this)
{
if(this[prop] instanceof Node && this[prop].content == value) {
return parseInt(prop);
}
}
}
return null;
}
this.clone = function()
{
var newList = new List();
this.goto_begin();
do
{
newList.append(this.head.content);
}
while (this.next());
this.goto_begin();
return newList;
}
this.swap = function(node1,...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.