mirror of
https://github.com/unidoc/unipdf.git
synced 2025-05-04 22:17:22 +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 (_b IntsMap )Add (key uint64 ,value int ){_b [key ]=append (_b [key ],value )};func (_d IntsMap )GetSlice (key uint64 )([]int ,bool ){_cg ,_ba :=_d [key ];if !_ba {return nil ,false ;
|
|
};return _cg ,true ;};func (_fae NumSlice )GetIntSlice ()[]int {_bdf :=make ([]int ,len (_fae ));for _ee ,_bag :=range _fae {_bdf [_ee ]=int (_bag );};return _bdf ;};type IntSlice []int ;func (_dbc *NumSlice )AddInt (v int ){*_dbc =append (*_dbc ,float32 (v ))};
|
|
func (_fa *IntSlice )Copy ()*IntSlice {_fc :=IntSlice (make ([]int ,len (*_fa )));copy (_fc ,*_fa );return &_fc ;};type IntsMap map[uint64 ][]int ;func (_ec *Stack )top ()int {return len (_ec .Data )-1};func (_e *NumSlice )Add (v float32 ){*_e =append (*_e ,v )};
|
|
func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_db IntsMap )Delete (key uint64 ){delete (_db ,key )};func (_de *IntSlice )Add (v int )error {if _de ==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");
|
|
};*_de =append (*_de ,v );return nil ;};func (_cf IntSlice )Size ()int {return len (_cf )};func (_fde IntSlice )Get (index int )(int ,error ){if index > len (_fde )-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 _fde [index ],nil ;};func (_gg *Stack )Pop ()(_fe interface{},_bdb bool ){_fe ,_bdb =_gg .peek ();if !_bdb {return nil ,_bdb ;};_gg .Data =_gg .Data [:_gg .top ()];return _fe ,true ;};func (_bb *Stack )peek ()(interface{},bool ){_fg :=_bb .top ();
|
|
if _fg ==-1{return nil ,false ;};return _bb .Data [_fg ],true ;};func NewNumSlice (i int )*NumSlice {_bd :=NumSlice (make ([]float32 ,i ));return &_bd };func (_fcg NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_fcg )-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 _fcg [i ],nil ;};type NumSlice []float32 ;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 (_fb IntsMap )Get (key uint64 )(int ,bool ){_ca ,_fd :=_fb [key ];
|
|
if !_fd {return 0,false ;};if len (_ca )==0{return 0,false ;};return _ca [0],true ;};func Max (x ,y int )int {if x > y {return x ;};return y ;};func NewIntSlice (i int )*IntSlice {_a :=IntSlice (make ([]int ,i ));return &_a };func (_g *Stack )Len ()int {return len (_g .Data )};
|
|
func (_dd *Stack )Push (v interface{}){_dd .Data =append (_dd .Data ,v )};func (_gb *Stack )Peek ()(_aed interface{},_gd bool ){return _gb .peek ()};func (_ag NumSlice )GetInt (i int )(int ,error ){const _ae ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_ag )-1{return 0,_f .Errorf (_ae ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );
|
|
};_cb :=_ag [i ];return int (_cb +Sign (_cb )*0.5),nil ;};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 ;}; |