unioffice/algo/algo.go
2023-12-12 23:20:29 +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 _c "strconv";
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_d ,_gae :=0,0;for _d < len (lhs )&&_gae < len (rhs ){_da :=lhs [_d ];_b :=rhs [_gae ];_e :=_ga (_da );_db :=_ga (_b );switch {case _e &&!_db :return true ;case !_e &&_db :return false ;case !_e &&!_db :if _da !=_b {return _da < _b ;
};_d ++;_gae ++;default:_ff :=_d +1;_bf :=_gae +1;for _ff < len (lhs )&&_ga (lhs [_ff ]){_ff ++;};for _bf < len (rhs )&&_ga (rhs [_bf ]){_bf ++;};_dac ,_ :=_c .ParseUint (lhs [_d :_ff ],10,64);_fff ,_ :=_c .ParseUint (rhs [_d :_bf ],10,64);if _dac !=_fff {return _dac < _fff ;
};_d =_ff ;_gae =_bf ;};};return len (lhs )< len (rhs );};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_fg :=make ([]byte ,len (s )*cnt );_cf :=[]byte (s );for _bc :=0;_bc < cnt ;_bc ++{copy (_fg [_bc :],_cf );};return string (_fg );
};func _ga (_f byte )bool {return _f >='0'&&_f <='9'};