mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
23 lines
3.8 KiB
Go
23 lines
3.8 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 basic ;import _d "github.com/unidoc/unipdf/v3/internal/jbig2/errors";type IntsMap map[uint64 ][]int ;func (_dd *NumSlice )Add (v float32 ){*_dd =append (*_dd ,v )};func NewIntSlice (i int )*IntSlice {_eb :=IntSlice (make ([]int ,i ));return &_eb };
|
|
func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_fc *NumSlice )AddInt (v int ){*_fc =append (*_fc ,float32 (v ))};func (_ce NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_ce )-1{return 0,_d .Errorf ("\u004e\u0075\u006dS\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};return _ce [i ],nil ;};func (_bc IntsMap )Delete (key uint64 ){delete (_bc ,key )};func (_ba *Stack )peek ()(interface{},bool ){_bg :=_ba .top ();if _bg ==-1{return nil ,false ;};return _ba .Data [_bg ],true ;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;
|
|
};return -1.0;};func (_gc NumSlice )GetInt (i int )(int ,error ){const _eca ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_gc )-1{return 0,_d .Errorf (_eca ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};_cg :=_gc [i ];return int (_cg +Sign (_cg )*0.5),nil ;};func Min (x ,y int )int {if x < y {return x ;};return y ;};type NumSlice []float32 ;func (_cb *Stack )Push (v interface{}){_cb .Data =append (_cb .Data ,v )};func (_c IntSlice )Size ()int {return len (_c )};
|
|
func (_ec IntSlice )Get (index int )(int ,error ){if index > len (_ec )-1{return 0,_d .Errorf ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0047\u0065\u0074","\u0069\u006e\u0064\u0065x:\u0020\u0025\u0064\u0020\u006f\u0075\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006eg\u0065",index );
|
|
};return _ec [index ],nil ;};func (_a *IntSlice )Add (v int )error {if _a ==nil {return _d .Error ("\u0049\u006e\u0074S\u006c\u0069\u0063\u0065\u002e\u0041\u0064\u0064","\u0073\u006c\u0069\u0063\u0065\u0020\u006e\u006f\u0074\u0020\u0064\u0065f\u0069\u006e\u0065\u0064");
|
|
};*_a =append (*_a ,v );return nil ;};func (_fg *Stack )Len ()int {return len (_fg .Data )};func (_ecb *Stack )top ()int {return len (_ecb .Data )-1};func Max (x ,y int )int {if x > y {return x ;};return y ;};func (_cf *Stack )Peek ()(_ddg interface{},_cd bool ){return _cf .peek ()};
|
|
type Stack struct{Data []interface{};Aux *Stack ;};func (_g IntsMap )Add (key uint64 ,value int ){_g [key ]=append (_g [key ],value )};func (_eg NumSlice )GetIntSlice ()[]int {_bb :=make ([]int ,len (_eg ));for _ea ,_fd :=range _eg {_bb [_ea ]=int (_fd );
|
|
};return _bb ;};func NewNumSlice (i int )*NumSlice {_daa :=NumSlice (make ([]float32 ,i ));return &_daa };func (_e IntsMap )Get (key uint64 )(int ,bool ){_ga ,_ee :=_e [key ];if !_ee {return 0,false ;};if len (_ga )==0{return 0,false ;};return _ga [0],true ;
|
|
};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_gf *Stack )Pop ()(_bbc interface{},_cge bool ){_bbc ,_cge =_gf .peek ();if !_cge {return nil ,_cge ;};_gf .Data =_gf .Data [:_gf .top ()];return _bbc ,true ;};func (_gab IntsMap )GetSlice (key uint64 )([]int ,bool ){_b ,_df :=_gab [key ];
|
|
if !_df {return nil ,false ;};return _b ,true ;};type IntSlice []int ;func (_da *IntSlice )Copy ()*IntSlice {_eba :=IntSlice (make ([]int ,len (*_da )));copy (_eba ,*_da );return &_eba ;}; |