// NewTrueRangeWithoutStorage creates a True Range Indicator (TrueRange) without storage
488184
func NewTrueRangeWithoutStorage(valueAvailableAction ValueAvailableActionFloat) (indicator *TrueRangeWithoutStorage, err error) {

	// an indicator without storage MUST have a value available action
	if valueAvailableAction == nil {
		return nil, ErrValueAvailableActionIsNil
	}

	lookback := 1
	ind := TrueRangeWithoutStorage{
		baseIndicatorWithFloatBounds: newBaseIndicatorWithFloatBounds(lookback, valueAvailableAction),
		periodCounter:                -1,
		previousClose:                0.0,
	}
	return &ind, nil
}
925903
func aboutToRestoreMethodsOnly(facadeName string, methodName string) error {
	fullName := facadeName + "." + methodName
	if !allowedMethodsAboutToRestore.Contains(fullName) {
		return aboutToRestoreError
	}
	return nil
}
1284208
func (rc *runContainer16) iremoveRange(firstOfRange, endx int) container {
	if firstOfRange >= endx {
		panic(fmt.Sprintf("request to iremove empty set [%v, %v),"+
			" nothing to do.", firstOfRange, endx))
		//return rc
	}
	x := newInterval16Range(uint16(firstOfRange), uint16(endx-1))
	rc.isubtract(x)
	return rc
}
755708
func (bc *bitmapContainer) iremoveRange(firstOfRange, lastOfRange int) container {
	bc.cardinality += resetBitmapRangeAndCardinalityChange(bc.bitmap, firstOfRange, lastOfRange)
	if bc.getCardinality() <= arrayDefaultMaxSize {
		return bc.toArrayContainer()
	}
	return bc
}
864709
func (r *runner) ensureStorage() {
	if r.runstackpos < r.runtrackcount*4 {
		doubleIntSlice(&r.runstack, &r.runstackpos)
	}
	if r.runtrackpos < r.runtrackcount*4 {
		doubleIntSlice(&r.runtrack, &r.runtrackpos)
	}
}
765126
func NewTreeNode(tree *TreeCache, path string, parent *TreeNode) *TreeNode {
	depth := 0
	if parent != nil {
		depth = parent.depth + 1
	}
	return &TreeNode{
		tree:     tree,
		state:    NodeStatePENDING,
		parent:   parent,
		path:     path,
		children: make(map[string]*TreeNode),
		depth:    depth,
	}
}
606663
func (a Int32Array) EqualWithoutOrder(b Int32Array) bool {
	if len(a) != len(b) {
		return false
	}

	sort.Sort(a)
	sort.Sort(b)

	for i := range a {
		if a[i] != b[i] {
			return false
		}
	}

	return true
}
269717
func NewTrueRangeWithSrcLen(sourceLength uint) (indicator *TrueRange, err error) {
	ind, err := NewTrueRange()

	// only initialise the storage if there is enough source data to require it
	if sourceLength-uint(ind.GetLookbackPeriod()) > 1 {
		ind.Data = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
	}

	return ind, err
}
902610
func NewTrimaWithoutStorage(timePeriod int, valueAvailableAction ValueAvailableActionFloat) (indicator *TrimaWithoutStorage, err error) {

	// an indicator without storage MUST have a value available action
	if valueAvailableAction == nil {
		return nil, ErrValueAvailableActionIsNil
	}

	// the minimum timeperiod for this indicator is 2
	if timePeriod < 2 {
		return nil, errors.New("timePeriod is less than the minimum (2)")
	}

	// check the maximum timeperiod
	if timePeriod > MaximumLookbackPeriod {
		return nil, errors.New("timePeriod is greater than the maximum (100000)")
	}

	lookback := timePeriod - 1
	ind := TrimaWithoutStorage{
		baseIndicatorWithFloatBounds: newBaseIndicatorWithFloatBounds(lookback, valueAvailableAction),
		timePeriod:                   timePeriod,
	}

	var sma1Period int
	var sma2Period int

	if timePeriod%2 == 0 {
		// even
		sma1Period = timePeriod / 2
		sma2Period = (timePeriod / 2) + 1
	} else {
		// odd
		sma1Period = (timePeriod + 1) / 2
		sma2Period = (timePeriod + 1) / 2
	}

	ind.sma1, err = NewSmaWithoutStorage(sma1Period, func(dataItem float64, streamBarIndex int) {
		ind.currentSma = dataItem
		ind.sma2.ReceiveTick(dataItem, streamBarIndex)
	})

	ind.sma2, _ = NewSmaWithoutStorage(sma2Period, func(dataItem float64, streamBarIndex int) {

		result := dataItem

		ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
	})

	return &ind, err
}
462147
func NewTrytes(s string) (Trytes, error) {
	err := ValidTrytes(s)
	return s, err
}
174880
func (a *Astilectron) NewTray(o *TrayOptions) *Tray {
	return newTray(o, a.canceller, a.dispatcher, a.identifier, a.writer)
}
313169
func NewDxWithoutStorage(timePeriod int, valueAvailableAction ValueAvailableActionFloat) (indicator *DxWithoutStorage, err error) {

	// an indicator without storage MUST have a value available action
	if valueAvailableAction == nil {
		return nil, ErrValueAvailableActionIsNil
	}

	// the minimum timeperiod for this indicator is 2
	if timePeriod < 2 {
		return nil, errors.New("timePeriod is less than the minimum (2)")
	}

	// check the maximum timeperiod
	if timePeriod > MaximumLookbackPeriod {
		return nil, errors.New("timePeriod is greater than the maximum (100000)")
	}

	lookback := 2
	if timePeriod > 1 {
		lookback = timePeriod
	}

	ind := DxWithoutStorage{
		baseIndicatorWithFloatBounds: newBaseIndicatorWithFloatBounds(lookback, valueAvailableAction),
		currentPlusDi:                0.0,
		currentMinusDi:               0.0,
		timePeriod:                   timePeriod,
	}

	ind.minusDI, err = NewMinusDi(timePeriod)

	ind.minusDI.valueAvailableAction = func(dataItem float64, streamBarIndex int) {
		ind.currentMinusDi = dataItem
	}

	ind.plusDI, err = NewPlusDi(timePeriod)

	ind.plusDI.valueAvailableAction = func(dataItem float64, streamBarIndex int) {
		ind.currentPlusDi = dataItem

		var result float64
		tmp := ind.currentMinusDi + ind.currentPlusDi
		if tmp != 0.0 {
			result = 100.0 * (math.Abs(ind.currentMinusDi-ind.currentPlusDi) / tmp)
		} else {
			result = 0.0
		}

		ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
	}

	return &ind, err
}
315798
func (a *MinMaxAllocator) AllocateNext() (int, bool, error) {
	a.lock.Lock()
	defer a.lock.Unlock()

	// Fast check if we're out of items
	if a.free <= 0 {
		return 0, false, ErrRangeFull
	}

	// Scan from the minimum until we find a free item
	for i := a.min; i <= a.max; i++ {
		if !a.has(i) {
			a.used[i] = true
			a.free--
			return i, true, nil
		}
	}

	// no free item found, but a.free != 0
	return 0, false, ErrInternal
}
825722
func NewKamaWithoutStorage(timePeriod int, valueAvailableAction ValueAvailableActionFloat) (indicator *KamaWithoutStorage, err error) {

	// an indicator without storage MUST have a value available action
	if valueAvailableAction == nil {
		return nil, ErrValueAvailableActionIsNil
	}

	// the minimum timeperiod for this indicator is 2
	if timePeriod < 2 {
		return nil, errors.New("timePeriod is less than the minimum (2)")
	}

	// check the maximum timeperiod
	if timePeriod > MaximumLookbackPeriod {
		return nil, errors.New("timePeriod is greater than the maximum (100000)")
	}

	lookback := timePeriod
	ind := KamaWithoutStorage{
		baseIndicatorWithFloatBounds: newBaseIndicatorWithFloatBounds(lookback, valueAvailableAction),
		periodCounter:                (timePeriod + 1) * -1,
		constantMax:                  float64(2.0 / (30.0 + 1.0)),
		constantDiff:                 float64((2.0 / (2.0 + 1.0)) - (2.0 / (30.0 + 1.0))),
		sumROC:                       0.0,
		periodROC:                    0.0,
		periodHistory:                list.New(),
		previousClose:                math.SmallestNonzeroFloat64,
		timePeriod:                   timePeriod,
	}

	return &ind, nil
}
600322
func (db *DB) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
	return NewRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
}
1147073
func NewVarWithoutStorage(timePeriod int, valueAvailableAction ValueAvailableActionFloat) (indicator *VarWithoutStorage, err error) {

	// an indicator without storage MUST have a value available action
	if valueAvailableAction == nil {
		return nil, ErrValueAvailableActionIsNil
	}

	// the minimum timeperiod for this indicator is 1
	if timePeriod < 1 {
		return nil, errors.New("timePeriod is less than the minimum (1)")
	}

	// check the maximum timeperiod
	if timePeriod > MaximumLookbackPeriod {
		return nil, errors.New("timePeriod is greater than the maximum (100000)")
	}

	lookback := timePeriod - 1

	ind := VarWithoutStorage{
		baseIndicatorWithFloatBounds: newBaseIndicatorWithFloatBounds(lookback, valueAvailableAction),
		periodCounter:                0,
		periodHistory:                list.New(),
		mean:                         0.0,
		variance:                     0.0,
		timePeriod:                   timePeriod,
	}

	return &ind, nil
}
716622
func NewThriftTransportWithMaxBufferSize(service *Service, timeout time.Duration, maxLength uint32) *ThriftTransport {
	return &ThriftTransport{
		WrappedFactory: thrift.NewTFramedTransportFactoryMaxLength(thrift.NewTTransportFactory(), maxLength),
		service:        service,
		randSource:     rand.New(rand.NewSource(time.Now().UnixNano())),
		Dialer: net.Dialer{
			Timeout: timeout,
		},
		logger: log.NewContext(service.stateLog).With(logkey.Protocol, "thrift"),
	}
}