mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-05 19:30:30 +08:00
22 lines
3.8 KiB
Go
22 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 _f "github.com/unidoc/unipdf/v3/internal/jbig2/errors";func (_ga NumSlice )GetInt (i int )(int ,error ){const _ffb ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_ga )-1{return 0,_f .Errorf (_ffb ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};_dd :=_ga [i ];return int (_dd +Sign (_dd )*0.5),nil ;};func (_bg IntSlice )Get (index int )(int ,error ){if index > len (_bg )-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 _bg [index ],nil ;};type NumSlice []float32 ;func (_gf *IntSlice )Copy ()*IntSlice {_gb :=IntSlice (make ([]int ,len (*_gf )));copy (_gb ,*_gf );return &_gb ;};func (_fcg *Stack )Push (v interface{}){_fcg .Data =append (_fcg .Data ,v )};func (_cdb NumSlice )GetIntSlice ()[]int {_fc :=make ([]int ,len (_cdb ));
|
|
for _gc ,_da :=range _cdb {_fc [_gc ]=int (_da );};return _fc ;};func (_fa *Stack )Peek ()(_gbd interface{},_fad bool ){return _fa .peek ()};func NewIntSlice (i int )*IntSlice {_bd :=IntSlice (make ([]int ,i ));return &_bd };func Sign (v float32 )float32 {if v >=0.0{return 1.0;
|
|
};return -1.0;};func (_gd *Stack )top ()int {return len (_gd .Data )-1};func NewNumSlice (i int )*NumSlice {_ff :=NumSlice (make ([]float32 ,i ));return &_ff };func (_ae *Stack )peek ()(interface{},bool ){_fb :=_ae .top ();if _fb ==-1{return nil ,false ;
|
|
};return _ae .Data [_fb ],true ;};type IntsMap map[uint64 ][]int ;func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};type Stack struct{Data []interface{};Aux *Stack ;
|
|
};func (_d IntsMap )Add (key uint64 ,value int ){_d [key ]=append (_d [key ],value )};func (_ba *NumSlice )Add (v float32 ){*_ba =append (*_ba ,v )};func (_ab NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_ab )-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 _ab [i ],nil ;};func (_af *NumSlice )AddInt (v int ){*_af =append (*_af ,float32 (v ))};func (_bf IntsMap )Get (key uint64 )(int ,bool ){_c ,_cd :=_bf [key ];if !_cd {return 0,false ;};if len (_c )==0{return 0,false ;};return _c [0],true ;};type IntSlice []int ;
|
|
func (_dab *Stack )Pop ()(_e interface{},_ce bool ){_e ,_ce =_dab .peek ();if !_ce {return nil ,_ce ;};_dab .Data =_dab .Data [:_dab .top ()];return _e ,true ;};func (_ad *IntSlice )Add (v int )error {if _ad ==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");
|
|
};*_ad =append (*_ad ,v );return nil ;};func (_gbf IntSlice )Size ()int {return len (_gbf )};func (_aa IntsMap )Delete (key uint64 ){delete (_aa ,key )};func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_a IntsMap )GetSlice (key uint64 )([]int ,bool ){_g ,_bb :=_a [key ];
|
|
if !_bb {return nil ,false ;};return _g ,true ;};func Max (x ,y int )int {if x > y {return x ;};return y ;};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_fff *Stack )Len ()int {return len (_fff .Data )}; |