bbs的树状算法的补充程序
发布时间:2006-10-14 2:56:20   收集提供:gaoqian
ssql = "select gorders,glayer from bbs where gId=" & gId & " and goders> " & gorders & " order by goders  "
rs1.Open sql, conn1, adOpenForwardOnly, adLockOptimistic '查询比父贴
                                            ‘order_value大的order_value
If (rs1.EOF And rs1.BOF) Then
If gLayer >= 8 Then  '如果深度大于8,就设goerders,glayer跟回帖平行
   gorders = rs1("gorders")
   gLayer = rs1("glayer")
Else
  gorders = gorders + 256
  gLayer = gLayer + 1
End If
Else
  nextvalue = rs1("gorders")
  If (nextvalue - gorders) > 1 Then
   gorders = Int((gorders + nextvalue) / 2)
   gLayer = gLayer
  Else                             '跟跟贴平行
   gorders = rs1("gorders")
   gLayer = rs1("glayer")
End If
End If

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50