unioffice/algo/algo.go
2022-01-15 21:17:38 +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 _b "strconv";func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_bf :=make ([]byte ,len (s )*cnt );_bc :=[]byte (s );for _gfa :=0;_gfa < cnt ;_gfa ++{copy (_bf [_gfa :],_bc );};return string (_bf );};
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_cg ,_be :=0,0;for _cg < len (lhs )&&_be < len (rhs ){_gf :=lhs [_cg ];_beb :=rhs [_be ];_a :=_c (_gf );_gb :=_c (_beb );switch {case _a &&!_gb :return true ;case !_a &&_gb :return false ;case !_a &&!_gb :if _gf !=_beb {return _gf < _beb ;};_cg ++;_be ++;default:_ac :=_cg +1;_eg :=_be +1;for _ac < len (lhs )&&_c (lhs [_ac ]){_ac ++;};for _eg < len (rhs )&&_c (rhs [_eg ]){_eg ++;};_f ,_ :=_b .ParseUint (lhs [_cg :_ac ],10,64);_fa ,_ :=_b .ParseUint (rhs [_cg :_eg ],10,64);if _f !=_fa {return _f < _fa ;};_cg =_ac ;_be =_eg ;};};return len (lhs )< len (rhs );};func _c (_e byte )bool {return _e >='0'&&_e <='9'};