JSFiddle - React, Tailwind, and code Playground
JavaScript
/*
* www.clubcompy.com
*
* (C) 2010 Woldrich, Inc. All rights reserved
*/
var KidCompy = KidCompy || {};
/**
* This is a base prototype you can use to make any object directly a node in linked list, stack, queue's
*
* To use this type, you must have
*
* DLinkBase constructor.
*/
KidCompy.DLinkBase = function() {
};
KidCompy.DLinkBase.prototype = {
/*
* DLinkBase class info
*/
constructor : KidCompy.DLinkBase,
/*
* DLinkBase fields
*/
prev : null,
next : null,
/*
* DLinkBase member functions
*/
setPrev : function(prevDlink) {
this.prev = prevDlink;
},
getPrev : function() {
return(this.prev);
},
setNext : function(nextDlink) {
this.next = nextDlink;
},
getNext : function() {
return(this.next);
},
getObject : function() {
return(this);
},
reset : function() {
this.prev = null;
this.next = null;
},
isLinked : function() {
return(this.prev && this.next);
}
};
/**
* Double link node for doubly linked list, keeps reference to any object
*
* Extends DLinkBase by adding an obj pointer that allows us to keep objects that don't extend DLinkBase in linked list/queue/stack
*
* DLink constructor.
*
* @this {KidCompy.DLink}
* @constructor
*/
KidCompy.DLink = function(obj) {
KidCompy.DLinkBase.call(this); /* Call super-class constructor */
this.obj = obj;
};
KidCompy.DLink.prototype = new KidCompy.DLinkBase;
/*
* DLink class info
*/
KidCompy.DLink.prototype.constructor = KidCompy.DLink;
/*
* DLink fields
*/
KidCompy.DLink.prototype.obj = null;
/*
* DLink member functions
*/
/**
* @this {KidCompy.DLink}
* @returns {any}
*/
KidCompy.DLink.prototype.getObject = function() {
return(this.obj);
};
/**
* @this {KidCompy.DLink}
*/
KidCompy.DLink.prototype.reset = function() {
this.prev = null;
...