unioffice/algo/algo.go
2024-11-22 00:17:48 +00:00

18 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 _a "strconv";func _g (_dd byte )bool {return _dd >='0'&&_dd <='9'};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_ab :=make ([]byte ,len (s )*cnt );_ga :=[]byte (s );for _gbd :=0;_gbd < cnt ;_gbd ++{copy (_ab [_gbd :],_ga );
};return string (_ab );};
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_gb ,_gf :=0,0;for _gb < len (lhs )&&_gf < len (rhs ){_c :=lhs [_gb ];_b :=rhs [_gf ];_gba :=_g (_c );_e :=_g (_b );switch {case _gba &&!_e :return true ;case !_gba &&_e :return false ;case !_gba &&!_e :if _c !=_b {return _c < _b ;
};_gb ++;_gf ++;default:_ee :=_gb +1;_bc :=_gf +1;for _ee < len (lhs )&&_g (lhs [_ee ]){_ee ++;};for _bc < len (rhs )&&_g (rhs [_bc ]){_bc ++;};_ef ,_ :=_a .ParseUint (lhs [_gb :_ee ],10,64);_ge ,_ :=_a .ParseUint (rhs [_gb :_bc ],10,64);if _ef !=_ge {return _ef < _ge ;
};_gb =_ee ;_gf =_bc ;};};return len (lhs )< len (rhs );};