unioffice/algo/algo.go

18 lines
1.3 KiB
Go
Raw Normal View History

2020-08-23 14:15:53 +00:00
//
// 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/
2024-05-22 00:21:11 +00:00
package algo ;import _a "strconv";
2020-08-23 14:15:53 +00:00
// NaturalLess compares two strings in a human manner so rId2 sorts less than rId10
2024-05-22 00:21:11 +00:00
func NaturalLess (lhs ,rhs string )bool {_cf ,_aa :=0,0;for _cf < len (lhs )&&_aa < len (rhs ){_f :=lhs [_cf ];_b :=rhs [_aa ];_fe :=_c (_f );_fg :=_c (_b );switch {case _fe &&!_fg :return true ;case !_fe &&_fg :return false ;case !_fe &&!_fg :if _f !=_b {return _f < _b ;
};_cf ++;_aa ++;default:_dg :=_cf +1;_ce :=_aa +1;for _dg < len (lhs )&&_c (lhs [_dg ]){_dg ++;};for _ce < len (rhs )&&_c (rhs [_ce ]){_ce ++;};_ba ,_ :=_a .ParseUint (lhs [_cf :_dg ],10,64);_e ,_ :=_a .ParseUint (rhs [_cf :_ce ],10,64);if _ba !=_e {return _ba < _e ;
};_cf =_dg ;_aa =_ce ;};};return len (lhs )< len (rhs );};func _c (_g byte )bool {return _g >='0'&&_g <='9'};func RepeatString (s string ,cnt int )string {if cnt <=0{return "";};_ec :=make ([]byte ,len (s )*cnt );_fgc :=[]byte (s );for _gc :=0;_gc < cnt ;
_gc ++{copy (_ec [_gc :],_fgc );};return string (_ec );};