// return the most commonest item (in case of duplicated items!)
968167
func (list *List) Commonest() string {
	count := make(map[string]int)
	list.Each(func(s string) { count[s]++ })
	var c_string string
	var c_count int
	for k, v := range count {
		if v > c_count {
			c_string = k
			c_count = v
		}
	}
	return c_string
}
283598
func (r Product_Item_Category) GetQuestions() (resp []datatypes.Product_Item_Category_Question, err error) {
	err = r.Session.DoRequest("SoftLayer_Product_Item_Category", "getQuestions", nil, &r.Options, &resp)
	return
}
617141
func (items Items) ByKey() (res map[string]Item) {
	res = make(map[string]Item, len(items))
	for _, i := range items {
		_, present := res[i.Key]
		if present {
			panic(fmt.Errorf("Duplicate key %s", i.Key))
		}
		res[i.Key] = i
	}
	return
}
1373776
func removeBackendDuplicates(items []backend.Item) []backend.Item {
	// Use map to record duplicates as we find them.
	encountered := map[string]bool{}
	result := make([]backend.Item, 0, len(items))

	// Loop over all items, if it has not been seen before, append to result.
	for _, e := range items {
		_, ok := encountered[string(e.Key)]
		if !ok {
			// Record this element as an encountered element.
			encountered[string(e.Key)] = true

			// Append to result slice.
			result = append(result, e)
		}
	}

	return result
}
1020509
func (q *Queue) getItemByID(id uint64) (*Item, error) {
	// Check if empty or out of bounds.
	if q.Length() == 0 {
		return nil, ErrEmpty
	} else if id <= q.head || id > q.tail {
		return nil, ErrOutOfBounds
	}

	// Get item from database.
	var err error
	item := &Item{ID: id, Key: idToKey(id)}
	if item.Value, err = q.db.Get(item.Key, nil); err != nil {
		return nil, err
	}

	return item, nil
}
224379
func commonTime(modTimes []time.Time) (modTime time.Time, count int) {
	var maxima int // Counter for remembering max occurrence of elements.
	timeOccurenceMap := make(map[time.Time]int)
	// Ignore the uuid sentinel and count the rest.
	for _, time := range modTimes {
		if time == timeSentinel {
			continue
		}
		timeOccurenceMap[time]++
	}
	// Find the common cardinality from previously collected
	// occurrences of elements.
	for time, count := range timeOccurenceMap {
		if count > maxima || (count == maxima && time.After(modTime)) {
			maxima = count
			modTime = time
		}
	}
	// Return the collected common uuid.
	return modTime, maxima
}
1218367
func (d DoubleArray) CommonPrefixSearch(input string) (ids, lens []int) {
	var p, q int
	bufLen := len(d)
	for i, size := 0, len(input); i < size; i++ {
		if input[i] == terminator {
			return
		}
		p = q
		q = int(d[p].Base) + int(input[i])
		if q >= bufLen || int(d[q].Check) != p {
			break
		}
		ahead := int(d[q].Base) + int(terminator)
		if ahead < bufLen && int(d[ahead].Check) == q && int(d[ahead].Base) <= 0 {
			ids = append(ids, int(-d[ahead].Base))
			lens = append(lens, i+1)
		}
	}
	return
}
103317
func commonPrefix(l, r []string) []string {
	var i int
	for i = 0; i < len(l) && i < len(r); i++ {
		if l[i] != r[i] {
			break
		}
	}
	return l[:i]
}
458473
func (tc *TransCache) GetGroupItemIDs(chID, grpID string) (itmIDs []string) {
	tc.cacheMux.RLock()
	itmIDs = tc.cacheInstance(chID).GetGroupItemIDs(grpID)
	tc.cacheMux.RUnlock()
	return
}
770721
func Repeat(value interface{}, count int) Query {
	return Query{
		Iterate: func() Iterator {
			index := 0

			return func() (item interface{}, ok bool) {
				if index >= count {
					return nil, false
				}

				item, ok = value, true

				index++
				return
			}
		},
	}
}
528866
func (p *itemPool) Borrowed() int {
	p.poolLock.RLock()
	defer p.poolLock.RUnlock()
	count := 0
	for _, item := range p.itemMap {
		if item.checkedOut {
			count++
		}
	}
	return count
}
1084618
func (item *Item) TopLikers() []string {
	switch s := item.Toplikers.(type) {
	case string:
		return []string{s}
	case []string:
		return s
	}
	return nil
}
77371
func (ngram *NGramIndex) BestMatch(input string, threshold ...float64) (*SearchResult, error) {
	if ngram.index == nil {
		ngram.init()
	}
	tval, error := validateThresholdValues(threshold)
	if error != nil {
		return nil, error
	}
	variants, error := ngram.match(input, tval)
	if error != nil {
		return nil, error
	}
	if len(variants) == 0 {
		return nil, errors.New("no matches found")
	}
	var result SearchResult
	maxsim := -1.0
	for _, val := range variants {
		if val.Similarity > maxsim {
			maxsim = val.Similarity
			result = val
		}
	}
	return &result, nil
}
949502
func (this *FastPFOR) getBestBFromData(in []int32) (bestb int32, bestc int32, maxb int32) {
	copy(this.freqs, zeroFreqs)
	// Get the count of all the leading bit positionsfor the slice
	// Mainly to figure out what's the best (most popular) bit position
	//for _, v := range in[k:kEnd] {
	for _, v := range in {
		this.freqs[encoding.LeadingBitPosition(uint32(v))]++
	}
	bestb = 32
	for this.freqs[bestb] == 0 {
		bestb--
	}
	maxb = bestb
	bestCost := bestb * DefaultBlockSize
	var cexcept int32
	bestc = cexcept
	// Find the cost of storing exceptions for each bit position
	for b := bestb - 1; b >= 0; b-- {
		cexcept += this.freqs[b+1]
		if cexcept < 0 {
			break
		}
		// the extra 8 is the cost of storing maxbits
		thisCost := cexcept*OverheadOfEachExcept + cexcept*(maxb-b) + b*DefaultBlockSize + 8
		if thisCost < bestCost {
			bestCost = thisCost
			bestb = b
			bestc = cexcept
		}
	}
	return
}
1108649
func (list *OccurrenceList) Find(id string) *Occurrence {
	for _, item := range list.Data {
		if item.ID == id {
			return item
		}
	}

	return nil
}
1295456
func (db *DB) RetrieveBestBlockHash() (string, error) {
	var blockHash string
	err := db.QueryRow(db.getBestBlockHashSQL).Scan(&blockHash)
	return blockHash, err
}
167324
func RandomItem(items ...string) string {
	var bytes = make([]byte, 1)
	rand.Read(bytes)
	return items[bytes[0]%byte(len(items))]
}