unioffice/algo/algo.go
2022-09-02 11:46:53 +00:00

15 lines
1.3 KiB
Go

//
// Copyright 2020 FoxyUtils ehf. All rights reserved.
//
// This is a commercial product and requires a license to operate.
// A trial license can be obtained at https://unidoc.io
//
// DO NOT EDIT: generated by unitwist Go source code obfuscator.
//
// Use of this source code is governed by the UniDoc End User License Agreement
// terms that can be accessed at https://unidoc.io/eula/
package algo ;import _g "strconv";func _cb (_gc byte )bool {return _gc >='0'&&_gc <='9'};
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_e ,_d :=0,0;for _e < len (lhs )&&_d < len (rhs ){_ge :=lhs [_e ];_cg :=rhs [_d ];_f :=_cb (_ge );_ee :=_cb (_cg );switch {case _f &&!_ee :return true ;case !_f &&_ee :return false ;case !_f &&!_ee :if _ge !=_cg {return _ge < _cg ;};_e ++;_d ++;default:_a :=_e +1;_eg :=_d +1;for _a < len (lhs )&&_cb (lhs [_a ]){_a ++;};for _eg < len (rhs )&&_cb (rhs [_eg ]){_eg ++;};_cf ,_ :=_g .ParseUint (lhs [_e :_a ],10,64);_dg ,_ :=_g .ParseUint (rhs [_e :_eg ],10,64);if _cf !=_dg {return _cf < _dg ;};_e =_a ;_d =_eg ;};};return len (lhs )< len (rhs );};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_df :=make ([]byte ,len (s )*cnt );_aa :=[]byte (s );for _dd :=0;_dd < cnt ;_dd ++{copy (_df [_dd :],_aa );};return string (_df );};