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 _e "github.com/unidoc/unipdf/v3/internal/jbig2/errors";func (_dd NumSlice )GetInt (i int )(int ,error ){const _ba ="\u0047\u0065\u0074\u0049\u006e\u0074";if i < 0||i > len (_dd )-1{return 0,_e .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 );
|
|
};_aea :=_dd [i ];return int (_aea +Sign (_aea )*0.5),nil ;};type IntsMap map[uint64 ][]int ;func (_cf *NumSlice )Add (v float32 ){*_cf =append (*_cf ,v )};func Abs (v int )int {if v > 0{return v ;};return -v ;};func (_db *NumSlice )AddInt (v int ){*_db =append (*_db ,float32 (v ))};
|
|
func (_cc *Stack )peek ()(interface{},bool ){_cg :=_cc .top ();if _cg ==-1{return nil ,false ;};return _cc .Data [_cg ],true ;};func (_eb *IntSlice )Copy ()*IntSlice {_ff :=IntSlice (make ([]int ,len (*_eb )));copy (_ff ,*_eb );return &_ff ;};func NewNumSlice (i int )*NumSlice {_ae :=NumSlice (make ([]float32 ,i ));
|
|
return &_ae };func (_dc *Stack )top ()int {return len (_dc .Data )-1};func (_fff IntSlice )Size ()int {return len (_fff )};func (_cb *Stack )Len ()int {return len (_cb .Data )};func (_be *Stack )Push (v interface{}){_be .Data =append (_be .Data ,v )};type NumSlice []float32 ;
|
|
func NewIntSlice (i int )*IntSlice {_dfa :=IntSlice (make ([]int ,i ));return &_dfa };func (_f IntsMap )Add (key uint64 ,value int ){_f [key ]=append (_f [key ],value )};func (_ag NumSlice )GetIntSlice ()[]int {_bag :=make ([]int ,len (_ag ));for _dg ,_ffb :=range _ag {_bag [_dg ]=int (_ffb );
|
|
};return _bag ;};type IntSlice []int ;func (_bd IntSlice )Get (index int )(int ,error ){if index > len (_bd )-1{return 0,_e .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 _bd [index ],nil ;};func (_b *IntSlice )Add (v int )error {if _b ==nil {return _e .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");
|
|
};*_b =append (*_b ,v );return nil ;};func (_edc NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_edc )-1{return 0,_e .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 _edc [i ],nil ;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};type Stack struct{Data []interface{};Aux *Stack ;};func (_bac *Stack )Pop ()(_ebd interface{},_fc bool ){_ebd ,_fc =_bac .peek ();if !_fc {return nil ,_fc ;};
|
|
_bac .Data =_bac .Data [:_bac .top ()];return _ebd ,true ;};func (_d IntsMap )Get (key uint64 )(int ,bool ){_ed ,_ce :=_d [key ];if !_ce {return 0,false ;};if len (_ed )==0{return 0,false ;};return _ed [0],true ;};func (_ffe *Stack )Peek ()(_ab interface{},_ca bool ){return _ffe .peek ()};
|
|
func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_df IntsMap )GetSlice (key uint64 )([]int ,bool ){_a ,_aa :=_df [key ];if !_aa {return nil ,false ;};return _a ,true ;
|
|
};func (_cd IntsMap )Delete (key uint64 ){delete (_cd ,key )};func Min (x ,y int )int {if x < y {return x ;};return y ;};func Max (x ,y int )int {if x > y {return x ;};return y ;}; |