gitlab.com/evatix-go/core@v1.3.55/defaultcapacity/OfSplits.go (about)

     1  package defaultcapacity
     2  
     3  import (
     4  	"gitlab.com/evatix-go/core/constants"
     5  )
     6  
     7  // OfSplits
     8  //
     9  // returns
    10  //  - limit:   -1, returns predictive length based on wholeLength (max 100)
    11  //  - limit: >= 0, returns limit if limit < wholeLength or
    12  //          else returns predictive length based on wholeLength (max 100)
    13  func OfSplits(wholeLength int, limit int) int {
    14  	hasLimit := limit > constants.MinusOne
    15  
    16  	if hasLimit && limit >= wholeLength {
    17  		return OfSearch(wholeLength)
    18  	} else if hasLimit && limit < wholeLength {
    19  		return limit
    20  	}
    21  
    22  	// no limit
    23  	return OfSearch(wholeLength)
    24  }