forked from unidoc/unioffice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgo.go
15 lines (13 loc) · 1.33 KB
/
algo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
//
// 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";func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_dd :=make ([]byte ,len (s )*cnt );_g :=[]byte (s );for _eg :=0;_eg < cnt ;_eg ++{copy (_dd [_eg :],_g );};return string (_dd );};func _b (_be byte )bool {return _be >='0'&&_be <='9'};
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
func NaturalLess (lhs ,rhs string )bool {_f ,_fb :=0,0;for _f < len (lhs )&&_fb < len (rhs ){_ff :=lhs [_f ];_db :=rhs [_fb ];_ffb :=_b (_ff );_e :=_b (_db );switch {case _ffb &&!_e :return true ;case !_ffb &&_e :return false ;case !_ffb &&!_e :if _ff !=_db {return _ff < _db ;};_f ++;_fb ++;default:_bg :=_f +1;_ed :=_fb +1;for _bg < len (lhs )&&_b (lhs [_bg ]){_bg ++;};for _ed < len (rhs )&&_b (rhs [_ed ]){_ed ++;};_ef ,_ :=_c .ParseUint (lhs [_f :_bg ],10,64);_fg ,_ :=_c .ParseUint (rhs [_f :_ed ],10,64);if _ef !=_fg {return _ef < _fg ;};_f =_bg ;_fb =_ed ;};};return len (lhs )< len (rhs );};