class listNode '链表节点 public Value public nextNodeend classclass modelList '链表操作类 private c_blnEof '节点到最后时为true,默认为false private c_blnBof '节点到开始时为true,默认为false private c_objList '链表对象 private c_objNownode '当前节点对象 private c_strWd '当前操作 private c_objValue '延用C#的规则,Object可以代替任意数据类型
private sub Class_Initialize() c_strWd="update" '默认为修改操作 set c_objList=nothing '初始化链表 c_blnBof=true c_blnEof=false end sub
private Sub Class_Terminate() set c_objList=nothing end sub
public sub Load(byval A_objList) '加载链表 set c_objList=A_objList call MoveFirst() '设置当前节点在开始位置 end sub
public sub Addnew() '添加新节点 c_strWd="addnew" set c_objNownode=new listNode'声明新节点 if isobject(c_objValue) then set c_objValue=nothing else c_objValue="" end if end sub
public sub Update() '保存添加或修改设置。 dim MM_objList dim MM_strNumber if c_strWd="addnew" then '将节点添加到链表内 if isobject(c_objValue) then set c_objNownode.value=c_objValue else c_objNownode.value=c_objValue end if set c_objNownode.nextNode=c_objList '记录好链接点 set c_objList=c_objNownode '记录添加结果 else set MM_objList=c_objList MM_strNumber=0 do while not MM_objList.nextNode is nothing '到结束端 if MM_objList is c_objNownode then exit do end if set MM_objList=MM_objList.nextNode MM_strNumber=MM_strNumber+1 loop if isobject(c_objValue) then execute("set c_objList" & replace(string(MM_strNumber,"0"),"0",".nextNode") & ".value=c_objValue") else execute("c_objList" & replace(string(MM_strNumber,"0"),"0",".nextNode") & ".value=c_objValue") end if end if end sub
public sub Delete() '删除当前节点。 dim MM_objList dim MM_strNumber set MM_objList=c_objList MM_strNumber=0 do while not MM_objList.nextNode is nothing '到结束端 if MM_objList is c_objNownode then exit do end if set MM_objList=MM_objList.nextNode MM_strNumber=MM_strNumber+1 loop if c_objNownode.nextNode is nothing then execute("set c_objList" & replace(string((MM_strNumber-1),"0"),"0",".nextNode") & "=nothing") else execute("set c_objList" & replace(string((MM_strNumber),"0"),"0",".nextNode") & "=c_objList" & replace(string((MM_strNumber+1),"0"),"0",".nextNode")) end if end sub
public sub MovePrevious()'将当前节点移动到上一个节点 dim MM_objNode,MM_blnDo if not c_blnBof then set MM_objNode=c_objList MM_blnDo=true do while not MM_objNode.nextNode is nothing '到结束端 if MM_objNode.nextNode is c_objNownode then set c_objNownode=MM_objNode exit do end if set MM_objNode=MM_objNode.nextNode loop end if set MM_objNode=nothing c_blnEof=c_objNownode.nextNode is nothing if isobject(c_objNownode.value) then set c_objValue=c_objNownode.value else c_objValue=c_objNownode.value end if end sub
public sub MoveNext()'将当前节点移动到下一个节点 if c_objNownode.nextNode is nothing then '到顶点啦。 c_blnEof=true else set c_objNownode=c_objNownode.nextNode c_blnBof=false if isobject(c_objNownode.value) then set c_objValue=c_objNownode.value else c_objValue=c_objNownode.value end if end if end sub
public sub MoveFirst()'将当前节点移动到开始位置 set c_objNownode=c_objList if isobject(c_objNownode.value) then set c_objValue=c_objNownode.value else c_objValue=c_objNownode.value end if c_blnEof=false end sub
public sub MoveLast()'将当前节点移动到结束位置 set c_objNownode=c_objList do while not c_objNownode.nextNode is nothing '当下一个节点为nothing时,当前节点为结束端 set c_objNownode=c_objNownode.nextNode '往结束端移动到。 loop if isobject(c_objNownode.value) then set c_objValue=c_objNownode.value else c_objValue=c_objNownode.value end if end sub
'将当前节点移动到之匹配的位置 ' 当A_objBlip为数字时则为移动到第几个节点,但A_objBlip大于节点总数时,当前节点定位在最后一个节点 ' 当A_objBlip为非数字型则是移动到node.value=A_objBlip的第一个节点 public sub Move(byval A_objBlip) dim MM_intCount set c_objNownode=c_objList MM_intCount=0 do MM_intCount=MM_intCount+1 if isobject(A_objBlip) then'对象 if c_objNownode.value is A_objBlip then exit do end if elseif isNumeric(A_objBlip) and lcase(typename(A_objBlip))<>"string" then'数字 if MM_intCount=A_objBlip then exit do end if else'字符 if c_objNownode.value=A_objBlip then exit do end if end if set c_objNownode=c_objNownode.nextNode '往结束端移动到。 loop while not c_objNownode.nextNode is nothing '当下一个节点为nothing时,当前节点为结束端 if isobject(c_objNownode.value) then set c_objValue=c_objNownode.value else c_objValue=c_objNownode.value end if end sub
public property get Count '返回节点数 dim MM_intCount dim MM_objNode set MM_objNode=c_objList MM_intCount=0 do while not MM_objNode is nothing MM_intCount=MM_intCount+1 set MM_objNode=MM_objNode.nextNode loop Count=MM_intCount end property
'/----------设置或返回节点操作--------/ public Default property get nValue '返回节点值 if isobject(c_objValue) then set nValue=c_objValue else nValue=c_objValue end if end property
public property let nValue(byval A_strValue) '设置节点值 c_objValue=A_strValue end property
public property set nValue(byval A_objValue) '设置节点值 set c_objValue=A_objValue end property '/----------设置或返回节点操作--------/
public property get eof '当前节点在结束位置时返回true eof=c_blnEof end property
public property get bof '当前节点在开始位置时返回true bof=c_blnBof end property
public property get list'返回当前操作的链表 set list=c_objList end property
end class