home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
classdict.sru
< prev
next >
Wrap
Text File
|
1997-08-06
|
3KB
|
137 lines
$PBExportHeader$classdict.sru
$PBExportComments$A classdict containing dictelements
forward
global type classdict from nonvisualobject
end type
end forward
global type classdict from nonvisualobject
end type
global classdict classdict
type variables
PRIVATE integer count = 0
PRIVATE dictelement firstElement, currentElement
end variables
forward prototypes
public function boolean contains (any key)
public subroutine set (any key, powerobject obj)
public function powerobject get (any key)
public subroutine remove (any key)
public function any firstkey ()
public function any nextkey ()
public function any currentkey ()
public function powerobject firstobject ()
public function powerobject nextobject ()
public function powerobject currentobject ()
public function integer size ()
end prototypes
public function boolean contains (any key);// is key present in dictionary
if firstElement.contains(key) > 0 then
return TRUE
end if
return FALSE
end function
public subroutine set (any key, powerobject obj);// set obj in dictionary using key
if isNull(key) then
return
end if
count = count + firstElement.set(key, obj)
end subroutine
public function powerobject get (any key);// get obj in dictionary using key
return firstElement.get(key)
end function
public subroutine remove (any key);// remove object from dictionary using key
count = count - firstElement.remove(key)
end subroutine
public function any firstkey ();// return first key in dictionary
currentElement = firstElement.nextElement
if isNull(currentElement) then
any nullkey
setNull(nullkey)
return nullkey
end if
return currentElement.ckey
end function
public function any nextkey ();// return next key in dictionary
if not isNull(currentElement) then
currentElement = currentElement.nextElement
end if
if isNull(currentElement) then
powerobject nullobj
setNull(nullobj)
return nullobj
end if
return currentElement.ckey
end function
public function any currentkey ();// return current key in dictionary
if isNull(currentElement) then
powerobject nullobj
setNull(nullobj)
return nullobj
end if
return currentElement.ckey
end function
public function powerobject firstobject ();// return first object in dictionary
currentElement = firstElement.nextElement
if isNull(currentElement) then
powerobject nullobj
setNull(nullobj)
return nullobj
end if
return currentElement.contents
end function
public function powerobject nextobject ();// return next object in dictionary
if not isNull(currentElement) then
currentElement = currentElement.nextElement
end if
if isNull(currentElement) then
powerobject nullobj
setNull(nullobj)
return nullobj
end if
return currentElement.contents
end function
public function powerobject currentobject ();// return current object in dictionary
if isNull(currentElement) then
powerobject nullobj
setNull(nullobj)
return nullobj
end if
return currentElement.contents
end function
public function integer size ();// return size of list
return count
end function
on classdict.create
TriggerEvent( this, "constructor" )
end on
on classdict.destroy
TriggerEvent( this, "destructor" )
end on
event constructor;// always add an empty/dummy first element
firstElement = create dictelement
setNull(currentElement)
end event
event destructor;// destroy firstElement
destroy firstElement
setNull(currentElement)
end event