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 _g "github.com/unidoc/unipdf/v3/internal/jbig2/errors";type Stack struct{Data []interface{};Aux *Stack ;};func Sign (v float32 )float32 {if v >=0.0{return 1.0;};return -1.0;};func Abs (v int )int {if v > 0{return v ;};return -v ;};
|
|
func (_ca *IntSlice )Add (v int )error {if _ca ==nil {return _g .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");};*_ca =append (*_ca ,v );
|
|
return nil ;};func NewNumSlice (i int )*NumSlice {_fd :=NumSlice (make ([]float32 ,i ));return &_fd };func (_fge NumSlice )GetIntSlice ()[]int {_ad :=make ([]int ,len (_fge ));for _fgf ,_ae :=range _fge {_ad [_fgf ]=int (_ae );};return _ad ;};func Max (x ,y int )int {if x > y {return x ;
|
|
};return y ;};func (_ed *Stack )top ()int {return len (_ed .Data )-1};func (_cg IntSlice )Size ()int {return len (_cg )};type NumSlice []float32 ;func NewIntSlice (i int )*IntSlice {_ff :=IntSlice (make ([]int ,i ));return &_ff };func (_gf *Stack )Pop ()(_fe interface{},_fc bool ){_fe ,_fc =_gf .peek ();
|
|
if !_fc {return nil ,_fc ;};_gf .Data =_gf .Data [:_gf .top ()];return _fe ,true ;};type IntSlice []int ;func (_fg *NumSlice )Add (v float32 ){*_fg =append (*_fg ,v )};func (_a IntsMap )Add (key uint64 ,value int ){_a [key ]=append (_a [key ],value )};
|
|
func (_gg *IntSlice )Copy ()*IntSlice {_gge :=IntSlice (make ([]int ,len (*_gg )));copy (_gge ,*_gg );return &_gge ;};func (_f IntsMap )Delete (key uint64 ){delete (_f ,key )};func (_de *NumSlice )AddInt (v int ){*_de =append (*_de ,float32 (v ))};func (_c IntsMap )Get (key uint64 )(int ,bool ){_gb ,_cf :=_c [key ];
|
|
if !_cf {return 0,false ;};if len (_gb )==0{return 0,false ;};return _gb [0],true ;};func Ceil (numerator ,denominator int )int {if numerator %denominator ==0{return numerator /denominator ;};return (numerator /denominator )+1;};func (_ea NumSlice )GetInt (i int )(int ,error ){const _ee ="\u0047\u0065\u0074\u0049\u006e\u0074";
|
|
if i < 0||i > len (_ea )-1{return 0,_g .Errorf (_ee ,"\u0069n\u0064\u0065\u0078\u003a\u0020\u0027\u0025\u0064\u0027\u0020\u006fu\u0074\u0020\u006f\u0066\u0020\u0072\u0061\u006e\u0067\u0065",i );};_ef :=_ea [i ];return int (_ef +Sign (_ef )*0.5),nil ;};
|
|
func (_gd *Stack )Peek ()(_ga interface{},_gc bool ){return _gd .peek ()};func (_bg IntsMap )GetSlice (key uint64 )([]int ,bool ){_e ,_bge :=_bg [key ];if !_bge {return nil ,false ;};return _e ,true ;};func (_bb *Stack )peek ()(interface{},bool ){_fb :=_bb .top ();
|
|
if _fb ==-1{return nil ,false ;};return _bb .Data [_fb ],true ;};type IntsMap map[uint64 ][]int ;func (_adb *Stack )Push (v interface{}){_adb .Data =append (_adb .Data ,v )};func Min (x ,y int )int {if x < y {return x ;};return y ;};func (_d IntSlice )Get (index int )(int ,error ){if index > len (_d )-1{return 0,_g .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 _d [index ],nil ;};func (_cd *Stack )Len ()int {return len (_cd .Data )};func (_df NumSlice )Get (i int )(float32 ,error ){if i < 0||i > len (_df )-1{return 0,_g .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 _df [i ],nil ;}; |