home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
setelement.sru
< prev
next >
Wrap
Text File
|
1997-08-06
|
3KB
|
130 lines
$PBExportHeader$setelement.sru
$PBExportComments$An element in a classset (actually a list element)
forward
global type setelement from nonvisualobject
end type
end forward
global type setelement from nonvisualobject
end type
global setelement setelement
type variables
powerobject contents
setelement nextElement, prevElement
end variables
forward prototypes
public function integer add (powerobject obj)
public function integer remove (integer index)
public function integer remove (powerobject obj)
public function integer contains (powerobject obj)
public function setelement get (integer index)
end prototypes
public function integer add (powerobject obj);// add at end if applicable
if (obj = contents) then
return 0
end if
if not isNull(nextElement) then
return nextElement.add(obj)
end if
setelement element
element = create setelement
element.contents = obj
element.prevElement = this
setNull(element.nextElement)
nextElement = element
return 1
end function
public function integer remove (integer index);// checks next element and remove is applicable
if isNull(nextElement) then
return 0
end if
if index = 0 then
setelement element
// remove nextElement from list and destroy it
element = nextElement
nextElement = element.nextElement
if not isNull(nextElement) then
nextElement.prevElement = this
end if
setNull(element.nextElement)
setNull(element.prevElement)
destroy element
return 1
end if
return nextElement.remove(index - 1)
end function
public function integer remove (powerobject obj);// checks next element and remove is applicable
if isNull(nextElement) then
return 0
end if
if obj = nextElement.contents then
setelement element
// remove nextElement from list and destroy it
element = nextElement
nextElement = element.nextElement
if not isNull(nextElement) then
nextElement.prevElement = this
end if
setNull(element.nextElement)
setNull(element.prevElement)
destroy element
if isNull(nextElement) then
return 1
end if
return (1 + nextElement.remove(obj))
end if
return nextElement.remove(obj)
end function
public function integer contains (powerobject obj);// checks next element
if isNull(nextElement) then
return 0
end if
if obj = nextElement.contents then
return (1 + nextElement.contains(obj))
end if
return nextElement.contains(obj)
end function
public function setelement get (integer index);// get bij index
if isNull(nextElement) then
powerobject nullobject
setNull(nullobject)
return nullobject
end if
if index = 0 then
return nextElement
end if
return nextElement.get(index - 1)
end function
on setelement.create
TriggerEvent( this, "constructor" )
end on
on setelement.destroy
TriggerEvent( this, "destructor" )
end on
event constructor;//
setNull(contents)
setNull(nextElement)
setNull(prevElement)
end event
event destructor;// destroy nextElement
setNull(contents)
setNull(prevElement)
if not isNull(nextElement) then
destroy nextElement
end if
setNull(nextElement)
end event