home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Multimedia Spanish 3
/
ProOne-MultimediaSpanishIII-WinMac.bin
/
pc
/
winextra
/
Netscape
/
SETUP
/
WIN32
/
NAV40L.Z
/
Stack.js
< prev
next >
Wrap
Text File
|
1997-10-22
|
1KB
|
75 lines
/* ==================================================================
FILE: Stack.js
DESCR: Stack object.
NOTES:
================================================================== */
/*
DESCR: Stack class.
PARAMS:
RETURNS:
NOTES:
*/
function stack()
{
this.pointer = -1
this.topItem
this.aItems = new Array
this.push = push
this.pop = pop
this.isEmpty = isEmpty
this.clear = clear
}
/*
DESCR:
PARAMS: item A variable of any type.
RETURNS:
NOTES:
*/
function push( item )
{
this.topItem = item
this.aItems[ ++this.pointer ] = item
}
/*
DESCR:
PARAMS:
RETURNS: The item.
NOTES:
*/
function pop()
{
if ( this.isEmpty() ) return null
this.topItem = this.aItems[ this.pointer - 1 ]
return this.aItems[ this.pointer-- ]
}
/*
DESCR: Empties the stack.
PARAMS:
RETURNS:
NOTES:
*/
function clear()
{
this.pointer = -1
this.topItem = null
}
/*
DESCR:
PARAMS:
RETURNS: true if the stack contains no members; false otherwise.
NOTES:
*/
function isEmpty()
{
return ( this.pointer < 0 ? true : false )
}
// End class definition: stack.