// NewIndex returns a new Index constructed from the list of mesos offers.
// If the KeyFunc is nil then offers are indexed by DefaultKeyFunc.
// The values of the returned Index are pointers to (not copies of) the offers of the slice receiver.
433997
func NewIndex(slice []mesos.Offer, kf KeyFunc) Index {
	if slice == nil {
		return nil
	}
	if kf == nil {
		kf = DefaultKeyFunc
	}
	index := make(Index, len(slice))
	for i := range slice {
		offer := &slice[i]
		index[kf(offer)] = offer
	}
	return index
}
527153
func (c *Menu) SetSelectedIndex(idx int) {
	if len(c.options) > 0 {
		if idx < 0 {
			idx = 0
		} else if idx >= len(c.options) {
			idx = len(c.options) - 1
		}
		c.SetSelectedOption(&c.options[idx])
	}
}
1120880
func (c *Client) OpenIndex(name string) *OpenIndexService {
	builder := NewOpenIndexService(c)
	builder.Index(name)
	return builder
}
60470
func (engine *Engine) CreateIndexes(bean interface{}) error {
	session := engine.NewSession()
	defer session.Close()
	return session.CreateIndexes(bean)
}
483868
func NewIndexOption() *DialogOption {
	return &DialogOption{
		Description: []string{
			"Choose a story by inserting the associated index.",
		},
		IsActive: func(stories []common.Story, depth int) bool {
			return len(stories) != 0
		},
		MatchesInput: func(input string, stories []common.Story) bool {
			index, err := strconv.Atoi(input)
			if err != nil {
				return false
			}
			return 1 <= index && index <= len(stories)
		},
		SelectStory: func(
			input string,
			stories []common.Story,
			currentDialog *Dialog,
		) (common.Story, error) {

			index, _ := strconv.Atoi(input)
			return stories[index-1], nil
		},
	}
}
781863
func (idx *index) AppendIndex(other *index) bool {
	var preRec record
	for i, rec := range other.Records {
		csize, rsize := rec.CompOffset-preRec.CompOffset, rec.RawOffset-preRec.RawOffset
		if !idx.AppendRecord(csize, rsize, rec.Type) {
			idx.Records = idx.Records[:len(idx.Records)-i] // Ensure atomic append
			return false
		}
		preRec = rec
	}
	return true
}
1325376
func newX(ch0 interface{}) *x {
	r := btXPool.Get().(*x)
	r.x[0].ch = ch0
	return r
}
1130635
func NewIndicesExistsTypeService(client *Client) *IndicesExistsTypeService {
	return &IndicesExistsTypeService{
		client: client,
		index:  make([]string, 0),
		typ:    make([]string, 0),
	}
}
415678
func NewReindexer(client *Client, source string, reindexerFunc ReindexerFunc) *Reindexer {
	return &Reindexer{
		sourceClient:  client,
		sourceIndex:   source,
		reindexerFunc: reindexerFunc,
		statsOnly:     true,
	}
}
859878
func New(minShift, depth int) *Index {
	if minShift == 0 {
		minShift = DefaultShift
	}
	if depth == 0 {
		depth = DefaultDepth
	}
	return &Index{Version: 0x2, minShift: uint32(minShift), depth: uint32(depth)}
}
873722
func (s *GlobalStore) nodeKeyIndex(addr common.Address, key []byte) (index int, found bool) {
	l := len(s.nodeKeys[addr])
	index = sort.Search(l, func(i int) bool {
		return bytes.Compare(s.nodeKeys[addr][i], key) >= 0
	})
	found = index < l && bytes.Equal(s.nodeKeys[addr][index], key)
	return index, found
}
1349496
func (s *DB) AddIndex(indexName string, columns ...string) *DB {
	scope := s.Unscoped().NewScope(s.Value)
	scope.addIndex(false, indexName, columns...)
	return scope.db
}
1137054
func (e *Entry) GetIndex(key string) int {
	for i := range e.Values {
		if e.Values[i].Key == key {
			return i
		}
	}
	return -1
}
109813
func New(path string, mapping mapping.IndexMapping) (Index, error) {
	return newIndexUsing(path, mapping, Config.DefaultIndexType, Config.DefaultKVStore, nil)
}
25902
func newBlockIndex(db database.DB, chainParams *chaincfg.Params) *blockIndex {
	return &blockIndex{
		db:          db,
		chainParams: chainParams,
		index:       make(map[chainhash.Hash]*blockNode),
		dirty:       make(map[*blockNode]struct{}),
	}
}
642332
func (kvp *KvProtoPluginWrapper) NewBroker(prefix string) keyval.ProtoBroker {
	return NewProtoBrokerWrapper(kvp.KvProtoPlugin.NewBroker(prefix), kvp.decrypter, kvp.decryptFunc)
}
1233586
func (c *Client) CreateIndex(name string) *IndicesCreateService {
	return NewIndicesCreateService(c).Index(name)
}