Class ::xo::OrderedComposite::IndexCompare

::xo::OrderedComposite::IndexCompare[i] create ...

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xotcl::Object[i]
::xotcl::Class create ::xo::OrderedComposite::IndexCompare \
     -superclass ::xotcl::Object

Methods (to be applied on instances)

  • __compare (scripted)

     <instance of xo::OrderedComposite::IndexCompare[i]> __compare

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_includelet_toc includelet_toc (test ) xo::OrderedComposite::IndexCompare instproc __compare xo::OrderedComposite::IndexCompare instproc __compare test_includelet_toc->xo::OrderedComposite::IndexCompare instproc __compare test_xowiki xowiki (test ) test_xowiki->xo::OrderedComposite::IndexCompare instproc __compare

    Testcases:
    includelet_toc, xowiki
    set by ${:__orderby}
    set x [$a set $by]
    set y [$b set $by]
    #:log "--value compare  $x $y] => [:__value_compare $x $y 0]"
    return [:__value_compare $x $y 0]
  • __value_compare (scripted)

    set xp [string first . $x]
    set yp [string first . $y]
    if {$xp == -1 && $yp == -1} {
      if {$x < $y} {
        return -1
      } elseif {$x > $y} {
        return 1
      } else {
        return $def
      }
    } elseif {$xp == -1} {
      set yh [string range $y 0 $yp-1]
      return [:__value_compare $x $yh -1]
    } elseif {$yp == -1} {
      set xh [string range $x 0 $xp-1]
      return [:__value_compare $xh $y 1]
    } else {
      set xh [string range $x 0 $xp]
      set yh [string range $y 0 $yp]
      #:log "xh=$xh yh=$yh"
      if {$xh < $yh} {
        return -1
      } elseif {$xh > $yh} {
        return 1
      } else {
        incr xp
        incr yp
        #:log "rest [string range $x $xp end] [string range $y $yp end]"
        return [:__value_compare [string range $x $xp end] [string range $y $yp end] $def]
      }
    }