// pageCountNative uses a native Go library to extract and return the number of
// pages in the PDF document. It returns an error if the filename is not of a
// PDF file, or if it failed to decode the PDF.
332101
func pageCountNative(filename string) (int, error) {
	f, err := os.Open(filename)
	if err != nil {
		return 0, err
	}
	defer f.Close()
	fi, err := f.Stat()
	if err != nil {
		return 0, err
	}
	p, err := pdf.NewReader(f, fi.Size())
	if err != nil {
		return 0, err
	}
	c := p.NumPage()
	if c < 1 {
		return 0, errors.New("encountered PDF without any pages")
	}
	return p.NumPage(), nil
}
597200
func GetPageCount(i int) uint64 {
	switch {
	case i > 0:
		// 返回成功数
		return pageSum[0]
	case i < 0:
		// 返回失败数
		return pageSum[1]
	case i == 0:
	}
	// 返回总数
	return pageSum[0] + pageSum[1]
}
151943
func (session *Session) FindAndCount(rowsSlicePtr interface{}, condiBean ...interface{}) (int64, error) {
	if session.isAutoClose {
		defer session.Close()
	}

	session.autoResetStatement = false
	err := session.find(rowsSlicePtr, condiBean...)
	if err != nil {
		return 0, err
	}

	sliceValue := reflect.Indirect(reflect.ValueOf(rowsSlicePtr))
	if sliceValue.Kind() != reflect.Slice && sliceValue.Kind() != reflect.Map {
		return 0, errors.New("needs a pointer to a slice or a map")
	}

	sliceElementType := sliceValue.Type().Elem()
	if sliceElementType.Kind() == reflect.Ptr {
		sliceElementType = sliceElementType.Elem()
	}
	session.autoResetStatement = true

	if session.statement.selectStr != "" {
		session.statement.selectStr = ""
	}
	if session.statement.OrderStr != "" {
		session.statement.OrderStr = ""
	}

	return session.Count(reflect.New(sliceElementType).Interface())
}
1270736
func (s *GetOperationsForResourceOutput) SetNextPageCount(v string) *GetOperationsForResourceOutput {
	s.NextPageCount = &v
	return s
}
1264682
func HugePageLimits(resourceList v1.ResourceList) map[int64]int64 {
	hugePageLimits := map[int64]int64{}
	for k, v := range resourceList {
		if v1helper.IsHugePageResourceName(k) {
			pageSize, _ := v1helper.HugePageSizeFromResourceName(k)
			if value, exists := hugePageLimits[pageSize.Value()]; exists {
				hugePageLimits[pageSize.Value()] = value + v.Value()
			} else {
				hugePageLimits[pageSize.Value()] = v.Value()
			}
		}
	}
	return hugePageLimits
}
1130984
func (p Pages) ByLanguage() Pages {

	const key = "pageSort.ByLanguage"

	pages, _ := spc.get(key, pageBy(languagePageSort).Sort, p)

	return pages
}
529568
func TotalPages(totalRows uint, limit uint) uint {
	return uint(math.Ceil(float64(totalRows) / float64(limit)))
}
68702
func (ns *Namespace) RuneCount(s interface{}) (int, error) {
	ss, err := cast.ToStringE(s)
	if err != nil {
		return 0, _errors.Wrap(err, "Failed to convert content to string")
	}
	return utf8.RuneCountInString(ss), nil
}
1238247
func paginate(page int, choices []string, sel int) ([]string, int) {
	// the number of elements to show in a single page
	var pageSize int
	// if the select has a specific page size
	if page != 0 {
		// use the specified one
		pageSize = page
		// otherwise the select does not have a page size
	} else {
		// use the package default
		pageSize = PageSize
	}

	var start, end, cursor int

	if len(choices) < pageSize {
		// if we dont have enough options to fill a page
		start = 0
		end = len(choices)
		cursor = sel

	} else if sel < pageSize/2 {
		// if we are in the first half page
		start = 0
		end = pageSize
		cursor = sel

	} else if len(choices)-sel-1 < pageSize/2 {
		// if we are in the last half page
		start = len(choices) - pageSize
		end = len(choices)
		cursor = sel - start

	} else {
		// somewhere in the middle
		above := pageSize / 2
		below := pageSize - above

		cursor = pageSize / 2
		start = sel - above
		end = sel + below
	}

	// return the subset we care about and the index
	return choices[start:end], cursor
}
19063
func ToCorrectPageSize(size int) int {
	if size <= 0 {
		size = 10
	} else if size > setting.API.MaxResponseItems {
		size = setting.API.MaxResponseItems
	}
	return size
}
755452
func (c *IPMemberList) NextPage() (*IPMemberList, error) {
	if !c.HasNextPage() {
		return nil, Error{"No next page"}
	}

	return c.getPage(c.Meta.NextPageUri)
}
73992
func (gp *GoPdf) AddPageWithOption(opt PageOption) {
	opt.PageSize = opt.PageSize.UnitsToPoints(gp.config.Unit)

	page := new(PageObj)
	page.init(func() *GoPdf {
		return gp
	})

	if !opt.isEmpty() { //use page option
		page.setOption(opt)
		gp.curr.pageSize = opt.PageSize
	} else { //use default
		gp.curr.pageSize = &gp.config.PageSize
	}

	page.ResourcesRelate = strconv.Itoa(gp.indexOfProcSet+1) + " 0 R"
	index := gp.addObj(page)
	if gp.indexOfFirstPageObj == -1 {
		gp.indexOfFirstPageObj = index
	}
	gp.curr.IndexOfPageObj = index

	//reset
	gp.indexOfContent = -1
	gp.resetCurrXY()
}
91785
func (p *Page) GetPageName() string {
	if p == nil || p.PageName == nil {
		return ""
	}
	return *p.PageName
}
502844
func (s *AutoScaleService) GetCounterByName(name string, opts ...OptionFunc) (*Counter, int, error) {
	id, count, err := s.GetCounterID(name, opts...)
	if err != nil {
		return nil, count, err
	}

	r, count, err := s.GetCounterByID(id, opts...)
	if err != nil {
		return nil, count, err
	}
	return r, count, nil
}
546228
func (r *PaginationResult) NextPage() *common.Pagination {
	if r.PageNumber*r.PageRecordCount >= r.TotalRecordCount {
		return nil
	}
	return &common.Pagination{PageNumber: r.PageNumber + 1, PageSize: r.PageRecordCount}
}
364497
func (p *page) leafPageElement(index uint16) *leafPageElement {
	n := &((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[index]
	return n
}
771171
func (s *AutoScaleService) GetCounterByID(id string, opts ...OptionFunc) (*Counter, int, error) {
	p := &ListCountersParams{}
	p.p = make(map[string]interface{})

	p.p["id"] = id

	for _, fn := range append(s.cs.options, opts...) {
		if err := fn(s.cs, p); err != nil {
			return nil, -1, err
		}
	}

	l, err := s.ListCounters(p)
	if err != nil {
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", id)) {
			return nil, 0, fmt.Errorf("No match found for %s: %+v", id, l)
		}
		return nil, -1, err
	}

	if l.Count == 0 {
		return nil, l.Count, fmt.Errorf("No match found for %s: %+v", id, l)
	}

	if l.Count == 1 {
		return l.Counters[0], l.Count, nil
	}
	return nil, l.Count, fmt.Errorf("There is more then one result for Counter UUID: %s!", id)
}