// ZRemRangeByLex remvoes members in [min, max] lexicographically
761452
func (db *DB) ZRemRangeByLex(key []byte, min []byte, max []byte, rangeType uint8) (int64, error) {
	if min == nil {
		min = db.zEncodeStartSetKey(key)
	} else {
		min = db.zEncodeSetKey(key, min)
	}
	if max == nil {
		max = db.zEncodeStopSetKey(key)
	} else {
		max = db.zEncodeSetKey(key, max)
	}

	t := db.zsetBatch
	t.Lock()
	defer t.Unlock()

	it := db.bucket.RangeIterator(min, max, rangeType)
	defer it.Close()

	var n int64
	for ; it.Valid(); it.Next() {
		t.Delete(it.RawKey())
		n++
	}

	if err := t.Commit(); err != nil {
		return 0, err
	}

	return n, nil
}
791867
func (r *Redis) ZRevRank(key, member string) (int64, error) {
	rp, err := r.ExecuteCommand("ZREVRANK", key, member)
	if err != nil {
		return -1, err
	}
	if rp.Type == ErrorReply {
		return -1, errors.New(rp.Error)
	}
	if rp.Type == IntegerReply {
		return rp.Integer, nil
	}
	if rp.Type == BulkReply {
		return -1, nil
	}
	return -1, errors.New("ZREVRANK reply protocol error")
}
1349777
func (db *DB) ZRevRange(key []byte, start int, stop int) ([]ScorePair, error) {
	return db.ZRangeGeneric(key, start, stop, true)
}
437538
func (db *DB) ZRemRangeByRank(key []byte, start int, stop int) (int64, error) {
	offset, count, err := db.zParseLimit(key, start, stop)
	if err != nil {
		return 0, err
	}

	var rmCnt int64

	t := db.zsetBatch
	t.Lock()
	defer t.Unlock()

	rmCnt, err = db.zRemRange(t, key, MinScore, MaxScore, offset, count)
	if err == nil {
		err = t.Commit()
	}

	return rmCnt, err
}
823761
func (m *Miniredis) ZRem(k, member string) (bool, error) {
	return m.DB(m.selectedDB).ZRem(k, member)
}
1078434
func (vals *ValidatorSet) applyRemovals(deletes []*Validator) {

	existing := vals.Validators

	merged := make([]*Validator, len(existing)-len(deletes))
	i := 0

	// Loop over deletes until we removed all of them.
	for len(deletes) > 0 {
		if bytes.Equal(existing[0].Address, deletes[0].Address) {
			deletes = deletes[1:]
		} else { // Leave it in the resulting slice.
			merged[i] = existing[0]
			i++
		}
		existing = existing[1:]
	}

	// Add the elements which are left.
	for j := 0; j < len(existing); j++ {
		merged[i] = existing[j]
		i++
	}

	vals.Validators = merged[:i]
}
624608
func (c *syncClient) Zrangebyscore(arg0 string, arg1 float64, arg2 float64) (result [][]byte, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(fmt.Sprintf("%e", arg1))
	arg2bytes := []byte(fmt.Sprintf("%e", arg2))

	var resp Response
	resp, err = c.conn.ServiceRequest(&ZRANGEBYSCORE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.GetMultiBulkData()
	}
	return result, err

}
1241406
func (c *Client) ZIncrBy(key string, increment int, member string) (string, error) {
	v, err := c.execWithKey(true, "ZINCRBY", key, increment, member)
	if err != nil {
		return "", err
	}
	return iface2str(v)
}
1236729
func UInt32Range(min, max uint32) gopter.Gen {
	return UInt64Range(uint64(min), uint64(max)).
		Map(uint64To32).
		WithShrinker(UInt32Shrinker).
		SuchThat(func(v uint32) bool {
			return v >= min && v <= max
		})
}
588050
func (v *version) LimitRanges() LimitRangeInformer {
	return &limitRangeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
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
}
361725
func (s *Server) LANSegmentMembers(segment string) ([]serf.Member, error) {
	if segment == "" {
		return s.LANMembers(), nil
	}

	return nil, structs.ErrSegmentsNotSupported
}
382075
func (c *asyncClient) Zrangebyscore(arg0 string, arg1 float64, arg2 float64) (result FutureBytesArray, err Error) {
	arg0bytes := []byte(arg0)
	arg1bytes := []byte(fmt.Sprintf("%e", arg1))
	arg2bytes := []byte(fmt.Sprintf("%e", arg2))

	var resp *PendingResponse
	resp, err = c.conn.QueueRequest(&ZRANGEBYSCORE, [][]byte{arg0bytes, arg1bytes, arg2bytes})
	if err == nil {
		result = resp.future.(FutureBytesArray)
	}
	return result, err

}
555879
func (pq *BlockPriorityQueue) RescanMinMax() {
	for i := range pq.bh {
		pq.updateMinMax(pq.bh[i].height)
	}
}
801147
func (c *Client) LANSegmentMembers(segment string) ([]serf.Member, error) {
	if segment == c.config.Segment {
		return c.LANMembers(), nil
	}

	return nil, fmt.Errorf("segment %q not found", segment)
}
480546
func ListRemoveByRankOp(binName string, rank int, returnType ListReturnType) *Operation {
	return &Operation{opType: _CDT_MODIFY, binName: binName, binValue: ListValue{_CDT_LIST_REMOVE_BY_RANK, IntegerValue(returnType), IntegerValue(rank)}, encoder: listGenericOpEncoder}
}
577012
func NewTermRangeQuery(min, max string) *query.TermRangeQuery {
	return query.NewTermRangeQuery(min, max)
}