// Returns map of {integerFactor: count, ...}
// This is a naive algorithm that will not work well for large prime n.
169360
func primeFactors(n int64) map[int64]int {
	factors := make(map[int64]int)
	for i := int64(2); i <= n; i++ {
		div, mod := n/i, n%i
		for mod == 0 {
			factors[i]++
			n = div
			div, mod = n/i, n%i
		}
	}
	return factors
}
671088
func countFunc(q query, t iterator) interface{} {
	var count = 0
	test := predicate(q)
	switch typ := q.Evaluate(t).(type) {
	case query:
		for node := typ.Select(t); node != nil; node = typ.Select(t) {
			if test(node) {
				count++
			}
		}
	}
	return float64(count)
}
572372
func (v *NestedListsI32x3) GetIntegerlist() (o [][][]int32) {
	if v != nil && v.Integerlist != nil {
		return v.Integerlist
	}

	return
}
715153
func (c *IterateChain) Count() (int64, error) {
	c.start()
	defer c.end()
	if err := c.it.Err(); err != nil {
		return 0, err
	}
	if size, exact := c.it.Size(); exact {
		return size, nil
	}
	done := c.ctx.Done()
	var cnt int64
iteration:
	for c.next() {
		select {
		case <-done:
			break iteration
		default:
		}
		cnt++
		for c.nextPath() {
			select {
			case <-done:
				break iteration
			default:
			}
			cnt++
		}
	}
	return cnt, c.it.Err()
}
338342
func (self *Operation) Count() (int64, error) {
	var result int64
	// params := Params{Params: []interface{}{self.Key}}
	params := []interface{}{self.Key}
	if err := self.Call("operation.count", params, &result); err != nil {
		return -1, err
	}
	return result, nil
}
250330
func (f Index) Count() (count int, err error) {
	it := f.db.NewIterator()
	defer it.Release()

	for ok := it.Seek(f.prefix); ok; ok = it.Next() {
		key := it.Key()
		if key[0] != f.prefix[0] {
			break
		}
		count++
	}
	return count, it.Error()
}
637018
func IntMap(result interface{}, err error) (map[string]int, error) {
	values, err := Values(result, err)
	if err != nil {
		return nil, err
	}
	if len(values)%2 != 0 {
		return nil, errors.New("redigo: IntMap expects even number of values result")
	}
	m := make(map[string]int, len(values)/2)
	for i := 0; i < len(values); i += 2 {
		key, ok := values[i].([]byte)
		if !ok {
			return nil, errors.New("redigo: IntMap key not a bulk string value")
		}
		value, err := Int(values[i+1], nil)
		if err != nil {
			return nil, err
		}
		m[string(key)] = value
	}
	return m, nil
}
904381
func StaticSizeOfMapWithSize(
	keyStaticSize, valueStaticSize int, count int) (bytes int) {
	keySize := mapKeyOrValueSizeWithIndirectPointerOverhead(keyStaticSize)
	valueSize := mapKeyOrValueSizeWithIndirectPointerOverhead(valueStaticSize)

	// See the comment of `B` field of `hmap` struct above.
	B := math.Ceil(math.Log2(float64(count) / mapLoadFactor))
	numBuckets := int(math.Exp2(B))

	return hmapStructSize +
		bucketSizeWithoutIndirectPointerOverhead*numBuckets +
		(keySize+valueSize)*count
}
41445
func (v *GuessProtocolStruct) GetMapField() (o map[string]string) {
	if v != nil && v.MapField != nil {
		return v.MapField
	}

	return
}
417489
func computeBlindingFactor(hopPubKey *btcec.PublicKey,
	hopSharedSecret []byte) Hash256 {

	sha := sha256.New()
	sha.Write(hopPubKey.SerializeCompressed())
	sha.Write(hopSharedSecret)

	var hash Hash256
	copy(hash[:], sha.Sum(nil))
	return hash
}
128035
func (p *PilosaKeyMapper) MapResult(field string, res interface{}) (mappedRes interface{}, err error) {
	log.Printf("mapping result: '%#v'", res)
	defer func() {
		log.Printf("mapped result: '%#v'", mappedRes)
	}()
	switch result := res.(type) {
	case uint64:
		// Count
		mappedRes = result
	case []interface{}:
		return p.mapSliceInterfaceResult(field, result)
	case map[string]interface{}:
		// Bitmap/Intersect/Difference/Union
		return p.mapBitmapResult(field, result)
	case bool:
		// SetBit/ClearBit
		mappedRes = result
	default:
		// Range? SetRowAttrs?
		mappedRes = result
	}
	return mappedRes, nil
}
355991
func (ngram *NGramIndex) countNgrams(inputNgrams []uint32) map[TokenID]int {
	counters := make(map[TokenID]int)
	for _, ngramHash := range inputNgrams {
		ngram.RLock()
		for tok := range ngram.index[ngramHash] {
			counters[tok]++
		}
		ngram.RUnlock()
	}
	return counters
}
428926
func GetMap(builder interface{}) map[string]interface{} {
	m := getBuilderMap(builder)
	structType := getBuilderStructType(reflect.TypeOf(builder))

	ret := make(map[string]interface{}, m.Size())

	m.ForEach(func(name string, val ps.Any) {
		list, isList := val.(ps.List)
		if isList {
			arrayType := anyArrayType

			if structType != nil {
				field, ok := (*structType).FieldByName(name)
				if ok {
					arrayType = field.Type
				}
			}

			val = listToSlice(list, arrayType).Interface()
		}

		ret[name] = val
	})

	return ret
}
815474
func (m ConcurrentMap) Count() int {
	count := 0
	for i := 0; i < SHARD_COUNT; i++ {
		shard := m[i]
		shard.RLock()
		count += len(shard.items)
		shard.RUnlock()
	}
	return count
}
262090
func randomInteger() int {
	return rand.Intn(nBoundary.end-nBoundary.start) + nBoundary.start
}
826397
func Map(x, inmin, inmax, outmin, outmax int64) int64 {
	return (x-inmin)*(outmax-outmin)/(inmax-inmin) + outmin
}
310675
func (mongo *MongoDB) Count() int {
	c, _ := mongo.Collection.Count()
	return c
}