unioffice/algo/algo.go
2022-02-25 19:20:45 +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 _f "strconv";func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_ag :=make ([]byte ,len (s )*cnt );_fce :=[]byte (s );for _e :=0;_e < cnt ;_e ++{copy (_ag [_e :],_fce );};return string (_ag );};func _g (_a byte )bool {return _a >='0'&&_a <='9'};
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_cg ,_d :=0,0;for _cg < len (lhs )&&_d < len (rhs ){_fc :=lhs [_cg ];_cd :=rhs [_d ];_af :=_g (_fc );_ce :=_g (_cd );switch {case _af &&!_ce :return true ;case !_af &&_ce :return false ;case !_af &&!_ce :if _fc !=_cd {return _fc < _cd ;};_cg ++;_d ++;default:_dc :=_cg +1;_df :=_d +1;for _dc < len (lhs )&&_g (lhs [_dc ]){_dc ++;};for _df < len (rhs )&&_g (rhs [_df ]){_df ++;};_aff ,_ :=_f .ParseUint (lhs [_cg :_dc ],10,64);_b ,_ :=_f .ParseUint (rhs [_cg :_df ],10,64);if _aff !=_b {return _aff < _b ;};_cg =_dc ;_d =_df ;};};return len (lhs )< len (rhs );};