2020-11-11 18:48:37 +00:00
|
|
|
package basic ;import _f "github.com/unidoc/unipdf/v3/internal/jbig2/errors";func (_ae IntsMap )GetSlice (key uint64 )([]int ,bool ){_e ,_ac :=_ae [key ];if !_ac {return nil ,false ;};return _e ,true ;};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_cb IntSlice )Get (index int )(int ,error ){if index > len (_cb )-1{return 0,_f .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 _cb [index ],nil ;};type IntsMap map[uint64 ][]int ;func (_fc NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_fc )-1{return 0,_f .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 _fc [i ],nil ;};func NewIntSlice (i int )*IntSlice {_g :=IntSlice (make ([]int ,i ));return &_g };func (_dd *NumSlice )Add (v float32 ){*_dd =append (*_dd ,v )};func (_a IntsMap )Get (key uint64 )(int ,bool ){_b ,_db :=_a [key ];if !_db {return 0,false ;};if len (_b )==0{return 0,false ;};return _b [0],true ;};type IntSlice []int ;func (_fcc *Stack )Pop ()(_gb interface{},_daf bool ){_gb ,_daf =_fcc .peek ();if !_daf {return nil ,_daf ;};_fcc .Data =_fcc .Data [:_fcc .top ()];return _gb ,true ;};type Stack struct{Data []interface{};Aux *Stack ;};func NewNumSlice (i int )*NumSlice {_ge :=NumSlice (make ([]float32 ,i ));return &_ge };func (_bg *Stack )top ()int {return len (_bg .Data )-1};func (_ag *Stack )Len ()int {return len (_ag .Data )};type NumSlice []float32 ;func (_ga *Stack )Peek ()(_bb interface{},_agc bool ){return _ga .peek ()};func (_da NumSlice )GetIntSlice ()[]int {_af :=make ([]int ,len (_da ));for _gg ,_ee :=range _da {_af [_gg ]=int (_ee );};return _af ;};func (_ff IntsMap )Delete (key uint64 ){delete (_ff ,key )};func (_bf *Stack )peek ()(interface{},bool ){_acd :=_bf .top ();if _acd ==-1{return nil ,false ;};return _bf .Data [_acd ],true ;};func Max (x ,y int )int {if x > y {return x ;};return y ;};func (_de NumSlice )GetInt (i int )(int ,error ){const _ba ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_de )-1{return 0,_f .Errorf (_ba ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );};_cbd :=_de [i ];return int (_cbd +Sign (_cbd )*0.5),nil ;};func (_ddd *NumSlice )AddInt (v int ){*_ddd =append (*_ddd ,float32 (v ))};func (_c IntsMap )Add (key uint64 ,value int ){_c [key ]=append (_c [key ],value )};func (_ab IntSlice )Size ()int {return len (_ab )};func (_ce *Stack )Push (v interface{}){_ce .Data =append (_ce .Data ,v )};func (_cd *IntSlice )Add (v int )error {if _cd ==nil {return _f .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");};*_cd =append (*_cd ,v );return nil ;};func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_eg *IntSlice )Copy ()*IntSlice {_aef :=IntSlice (make ([]int ,len (*_eg )));copy (_aef ,*_eg );return &_aef ;};
|