Ejemplo n.º 1
0
func (d *debugHistogram) PrintSorted() {
	if !printDebugOutput {
		return
	}
	if len(d.mapping) == 0 {
		return
	}
	var scores vector.IntVector
	inverseMapping := make(map[int]string)
	sum := 0
	for key, value := range d.mapping {
		inverseMapping[value] = key
		scores.Push(value)
		sum += value
	}
	scoresArray := sort.IntArray(scores)
	scoresArray.Sort()

	fmt.Fprintf(os.Stderr, "Debug histogram - sorted:\n")
	length := len(scoresArray)
	for i := 0; i < length; i++ {
		current := scoresArray[length-i-1]
		fmt.Fprintf(os.Stderr, "%s: %d (%2.1f%%)\n", inverseMapping[current], current, float(current)/float(sum)*100)
	}
}
Ejemplo n.º 2
0
func ints() {
	data := []int{74, 59, 238, -784, 9845, 959, 905, 0, 0, 42, 7586, -5467984, 7586}
	a := sort.IntArray(data)
	sort.Sort(a)
	if !sort.IsSorted(a) {
		panic()
	}
}